Re: custom view won't update
Re: custom view won't update
- Subject: Re: custom view won't update
- From: Shawn Erickson <email@hidden>
- Date: Tue, 11 Sep 2007 07:25:36 -0700
On Sep 11, 2007, at 5:16 AM, H M wrote:
It seems a little strange that an NSView subclass has IBActions/
IBOutlets... yet the above code seems to imply that.
hm, come to think of it, i'd say you're right, they should be in a
controller class. that means i have to access the variables using
accessor methods, but that shouldn't be a problem. the question is,
how do I get that controller class to update my view?
Can you please outline which classes contain which methods and
which is the NSView subclass? Also can you describe how they are
connected / instantiated in the nib?
the NSView subclass is called Sky, and it contains the 3 action
methods, the 3 outlets, drawRect: and all the necessary variables,
mostly double.
in InterfaceBuilder I subclassed NSView, renamed the new class,
added the outlets and the actions, then I instantiated it and
connected the sliders to their methods and outlets. after that, i
created the files and went back to xcode.
When you say you instantiated it... I assume you mean you dragged an
NSView off of the palette and into the nib object window (the one
with the "Instances, Classes, etc. " tabs at the top). If so then you
created a view that isn't a member of a view hierarchy yet. To "see"
this view you would need to programmatically add into a view
hierarchy of a window.
I also assume you dragged and dropped an NSView off of the palette
and into an instance of NSWindow. This is the one you see working
when you resize, etc. This is another instance of your custom view.
You could connect the actions of your sliders to this instance by
control dragging from the buttons and to this instance.
If you are using actions in your view consider making them more data
source like in naming... for example NSControl has IBActions name
like the following "takeXxxxValueFrom:".
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden