Re: Newbie: Simple display with NSView - problem
Re: Newbie: Simple display with NSView - problem
- Subject: Re: Newbie: Simple display with NSView - problem
- From: Graham Cox <email@hidden>
- Date: Sat, 4 Oct 2008 08:38:13 +1000
On 4 Oct 2008, at 1:19 am, Genu Mathew wrote:
Thank you for the reply. Is there any placeholder for the custom
view that I can use in the NIB file such that I can instantiate the
view in the code and then load it onto the window?
I can not hard code the filename into the custom view class and use
it in the NIB as the image to be displayed will not always be the
same and it can change depending on where the user will click on the
main window.
That's not how it should work.
If you have a view subclass then design it to handle any image file
given its filename - you wouldn't have a separate view subclass for
every individual file. I'm pretty sure this isn't what you're
proposing, but it could be one interpretation of your description!
In the NIB, just use a "custom view", then set its class to your class
name. Then you don't have to instantiate it in code at all - it's
already in existence in the NIB. When the NIB is loaded you can set
the filename of the image, most likely using the -awakeFromNib
message. To obtain the reference to the view, add an IBOutlet to its
controller and link it up in IB. Then you can use that outlet to refer
to the view.
hth,
Graham
_______________________________________________
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