Re: Help with creating CustomViews
Re: Help with creating CustomViews
- Subject: Re: Help with creating CustomViews
- From: Steven Degutis <email@hidden>
- Date: Tue, 23 Feb 2010 08:24:54 -0500
You're on the right track with NSViewController. Make an NSViewController
and a XIB specifically for this view controller. Set the -view outlet in
your NIB and make sure you name the File's Owner the same as your
NSViewController subclass. Make sure your initializer mentions the name of
the correct XIB it requires. Then, in the rest of your code, instantiate
your NSViewController subclass and ask for its NSView via the -view
accessor. Add the NSView anywhere you want. I often do this by using an
NSBox and using -setContentView:
-Steven
On Fri, Feb 19, 2010 at 4:20 PM, Jean-Henri Duteau
<email@hidden>wrote:
>
> On 2010-02-19, at 6:55 AM, Steven Degutis wrote:
>
> > It sounds a lot to me (and I could be wrong here) that you're trying to
> implement something along the lines of an ActiveX control as they were back
> when I used Visual Basic 5, in the sense that you want a "control" which is
> really a collection of other controls, and to be able to drag them around in
> IB and treat this collection as if they were a single control.
> >
> That's exactly what I want - a "control" which can be dragged around in IB
> and, more importantly, created a number of times. I want View that I can
> place on a window (or anywhere in IB) along a view controller. I can then
> point the controller at the model and everything will "just work".
>
>
> > What you're doing can easily be accomplished in code, by having an
> NSViewController that points to your own XIB file, and by creating instances
> of this view controller and inserting its view into other views. This is the
> canonical way. Not only do you get more flexibility by doing it in code (and
> a lot less repetition in IB) but this method allows you to encapsulate
> another level of abstractness inside your NSViewController subclass, thus
> cleaning up your code (a lot). This is what more experienced Cocoa coders
> generally do instead of what you're trying to do.
> >
> I'm sure that it can and that's exactly what my first try did - I have a
> custom NSViewController that points to my view's XIB file. I then added an
> instance of my view controller. The problem is that I'm stuck from there -
> I'm unsure how to get the view to appear where I want it to on the window.
> I've added a Custom View in the layout and set its class to my view's
> class. I attach the view to the view controller. And nothing happens and
> I'm unsure what to override or call to make it happen.
>
> Jean_______________________________________________
>
> 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
>
--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
_______________________________________________
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