• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Canonical way of loading compound UI components from a NIB into some other UI? [SOLVED?]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Canonical way of loading compound UI components from a NIB into some other UI? [SOLVED?]


  • Subject: Re: Canonical way of loading compound UI components from a NIB into some other UI? [SOLVED?]
  • From: Luke Evans <email@hidden>
  • Date: Thu, 6 Dec 2007 17:03:09 -0800

By way of an update and perhaps a conclusion.

Following my nose somewhat (and emboldened by the fact that "IB 3.x Plug-Ins aren't that bad"!), I've produced my first plug-in to solve my 'problem'.
In the spirit of reusability I've tried to solve the class problem that was bugging me (namely the unpacking of a view hierarchy from another NIB underneath a placeholder view, without the redundancy of leaving a level of view as the 'connection point', and as far as possible preserving encapsulation - the benefit of keeping all your 'compound control' in one NIB file.


So, I now have a IB plug in that implements one custom control called "SurrogateView". This manifests at design-time as a red rectangle with a diagonal cross, possessed of two string properties: viewControllerClassName and nibName.

At runtime, when the SurrogateView gets -awakeFromNIB, it attempts to instantiate the named NSViewController subclass, and initialises it with the nib file. It then obtains the loaded view, sets its own frame size onto this view and then deftly replaces itself as a subview of its parent with the loaded view.

Seems to work like a charm (so far!).

I'm still left with a nagging doubt about having to do this - or perhaps I should say surprise that there isn't a standard way to do this sort of thing, as it seems to me that one should quite commonly try to encapsulate useful bits of UI in separate NIBs and load them into other view hierarchies as needed. Of course, if you are developing a dynamic UI, then you'll be writing the code to replace subviews anyway, but when you just want to include a single 'static' instance of a compound control, then you don't want to be messing with code (in the same way that IB is supposed to let you capture prebuilt view hierarchies in the first place).

Anyway, a final thanks for the pointers - much appreciated.

-- Lwe


On 5-Dec-07, at 5:13 PM, Ricky Sharp wrote:


IB 3.x Plug-Ins aren't that bad. Look for my MyIBPlugin sample at <http://www.instantinteractive.com/private/samplecode/MyIBPlugin.zip > as a starting point. It doesn't contain an exact sample of what you want, but it's very easy:


...
You then basically have a shortcut of sorts. You can then drag in that single library template object into whatever and a copy of your pre-built NSView will be dropped into place. You can then of course inspect any objects in that hierarchy and make alterations as needed.


Of course you'll need to set up any bindings and/or make connections to controllers for each instance you drag in.


_______________________________________________

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


References: 
 >Canonical way of loading compound UI components from a NIB into some other UI? (From: Luke Evans <email@hidden>)
 >Re: Canonical way of loading compound UI components from a NIB into some other UI? (From: Joshua Emmons <email@hidden>)
 >Re: Canonical way of loading compound UI components from a NIB into some other UI? (From: Luke Evans <email@hidden>)
 >Re: Canonical way of loading compound UI components from a NIB into some other UI? (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: -[NSImage TIFFRepresentation] failing on the multiple files icon?
  • Next by Date: Empty Class Browser with 10.4 SDK target
  • Previous by thread: Re: Canonical way of loading compound UI components from a NIB into some other UI?
  • Next by thread: [CA] Create a "A la FrontRow" Button
  • Index(es):
    • Date
    • Thread