Re: iOS: multiple view controllers, one nib?
Re: iOS: multiple view controllers, one nib?
- Subject: Re: iOS: multiple view controllers, one nib?
- From: Shawn Erickson <email@hidden>
- Date: Wed, 18 May 2011 21:12:43 -0700
On Wed, May 18, 2011 at 11:53 AM, Nathan Sims
<email@hidden> wrote:
> I'm writing an iPad app that has its main screen subdivided into 4 equal regions, each with a UIView, all defined in one IB nib. I have a dedicated view controller class for each view. When I instantiate the view controller class for each quadrant's view with -initWithNibName:bundle:, I have to specify the same nib name for each:
>
> quad1VC = [[Quad1ViewController alloc] initWithNibName:@"QuadViewiPad" bundle:nil];
> quad2VC = [[Quad2ViewController alloc] initWithNibName:@"QuadViewiPad" bundle:nil];
> quad3VC = [[Quad3ViewController alloc] initWithNibName:@"QuadViewiPad" bundle:nil];
> quad4VC = [[Quad4ViewController alloc] initWithNibName:@"QuadViewiPad" bundle:nil];
>
> Will this properly connect each quadrant's view with the corresponding view controller, or should I have just one view controller for all 4 views?
initWithNibName:bundle: instantiates a unique object graph from the
objects serialized in the xib each time it is called. This object
graph is connected with the files owner as defined in your xib. I
assume the QuadNViewController class have a common base class with the
actions and outlets defined that your QuadViewiPad expect and that
class is setup as the class for the files owner.
So nothing prevents what you are doing but as Luke pointed out some
assumptions exist the could be problematic for you outside of your
xib/nib question.
You could always instantiate a xib (nib) yourself without using a
UIViewController subclass and still follow the model you are thinking.
-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