Re: iOS: multiple view controllers, one nib?
On May 18, 2011, at 9:12 PM, Shawn Erickson wrote: > 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. Thanks Shawn. I'm an iOS newb, so I realize I shouldn't try to force things to work "my" way, to "fight the framework". For the first go, I've taken Luke's advice and used a single view controller for now. This approach has the redeeming quality that it works! Once I get all the requirements implemented in my initial release, I'll have a better understanding of the dynamics of iOS and can then go back and refactor/rearchitect things to make it more elegant. It's an iterative learning process, quite fun actually! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
On Wed, May 18, 2011 at 11:53 AM, Nathan Sims 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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
I had a similar issue in my code and am unsure if my solution is correct. So if I'm doing this wrong, let me know. My strategy was to associated each custom view (MWView subclass of UITextField) with a handler (MWHandler subclass of NSObject). The MWHandler is a class whose interface and implementation reside inside the MWView's implementation file, so the MWView appears to be self-contained. The MWHandler holds pointers to the MWView's subviews that the MWHandler will need to update. Controls inside the MWView that should trigger actions are set up to notify the MWHandler (with addTarget:action:forControlEvents:). You need to watch out for retain cycles (where the MWHandler retains a pointer to the MWView which retains a pointer to the MWHandler). Code available on request (unless people tell me I've done it wrong), Aaron On May 18, 2011, at 12:32 PM, Nathan Sims wrote: > Hmm, but then how would each custom class communicate with the view elements? > NSNotifications? > > On May 18, 2011, at 12:27 PM, Eric E. Dolecki wrote: > >> I don't think so but you could always associate a custom Class with each of >> the UIViews to tuck most of the UIView specific code away from the view >> controller's code. >> >> >> Google Voice: (508) 656-0622 >> Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki >> http://blog.ericd.net >> >> >> >> On Wed, May 18, 2011 at 3:19 PM, Nathan Sims >> wrote: >> Okay, but won't that make for one mega-complex view controller? >> >> On May 18, 2011, at 11:58 AM, Luke the Hiesterman wrote: >> >>> The IB concerns aside, attempting to build your own "more than one view >>> controller on the screen" solution is currently fraught with peril, and >>> something you'll probably get wrong. The window expects to have a single >>> rootViewController to handle rotations and such. You're probably better off >>> having a single view controller and each of your quad views should just be >>> regular UIViews managed by the one view controller. And, if you did that, >>> all your views would naturally be built in the one nib that defines your >>> view controller :) >>> >>> Luke >>> >>> On May 18, 2011, at 11:53 AM, Nathan Sims 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? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com This email sent to luket...@apple.com >>> >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> 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: >> http://lists.apple.com/mailman/options/cocoa-dev/edolecki%40gmail.com >> >> This email sent to edole...@gmail.com >> > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/eeyore%40monsterworks.com > > This email sent to eey...@monsterworks.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
Okay, that looks like a "go". I certainly have my work cut out for me :) Thanks Luke, Eric, Mikkel. -Nate On May 18, 2011, at 12:40 PM, Mikkel Islay wrote: > On 18 May 2011, at 20:32, Nathan Sims wrote: > >> Hmm, but then how would each custom class communicate with the view >> elements? NSNotifications? > > From the View Controller Programming Guide: > Note: If you want to divide a view hierarchy into multiple subareas and > manage each one separately, use generic controller objects (custom objects > descending from NSObject) instead of view controller objects to manage each > subarea. Then use a single view controller object to manage the generic > controller objects. > http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html%23//apple_ref/doc/uid/TP40007457-CH112-SW10 > > NSNotification would be a way for your UIViewController to observe > drawing-related changes to your views. > > >> On May 18, 2011, at 12:27 PM, Eric E. Dolecki wrote: >> >>> I don't think so but you could always associate a custom Class with each of >>> the UIViews to tuck most of the UIView specific code away from the view >>> controller's code. >>> > > Mikkel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
Hmm, but then how would each custom class communicate with the view elements? NSNotifications? On May 18, 2011, at 12:27 PM, Eric E. Dolecki wrote: > I don't think so but you could always associate a custom Class with each of > the UIViews to tuck most of the UIView specific code away from the view > controller's code. > > > Google Voice: (508) 656-0622 > Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki > http://blog.ericd.net > > > > On Wed, May 18, 2011 at 3:19 PM, Nathan Sims > wrote: > Okay, but won't that make for one mega-complex view controller? > > On May 18, 2011, at 11:58 AM, Luke the Hiesterman wrote: > > > The IB concerns aside, attempting to build your own "more than one view > > controller on the screen" solution is currently fraught with peril, and > > something you'll probably get wrong. The window expects to have a single > > rootViewController to handle rotations and such. You're probably better off > > having a single view controller and each of your quad views should just be > > regular UIViews managed by the one view controller. And, if you did that, > > all your views would naturally be built in the one nib that defines your > > view controller :) > > > > Luke > > > > On May 18, 2011, at 11:53 AM, Nathan Sims 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? > >> > >> > >> ___ > >> > >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > >> > >> 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: > >> http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com > >> > >> This email sent to luket...@apple.com > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/edolecki%40gmail.com > > This email sent to edole...@gmail.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
I don't think so but you could always associate a custom Class with each of the UIViews to tuck most of the UIView specific code away from the view controller's code. Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki http://blog.ericd.net On Wed, May 18, 2011 at 3:19 PM, Nathan Sims wrote: > Okay, but won't that make for one mega-complex view controller? > > On May 18, 2011, at 11:58 AM, Luke the Hiesterman wrote: > > > The IB concerns aside, attempting to build your own "more than one view > controller on the screen" solution is currently fraught with peril, and > something you'll probably get wrong. The window expects to have a single > rootViewController to handle rotations and such. You're probably better off > having a single view controller and each of your quad views should just be > regular UIViews managed by the one view controller. And, if you did that, > all your views would naturally be built in the one nib that defines your > view controller :) > > > > Luke > > > > On May 18, 2011, at 11:53 AM, Nathan Sims 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? > >> > >> > >> ___ > >> > >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > >> > >> 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: > >> http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com > >> > >> This email sent to luket...@apple.com > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/edolecki%40gmail.com > > This email sent to edole...@gmail.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
Possibly. You'll have a better chance getting that right than doing your own view controller composition, though. Custom composition of view controllers isn't really supported in iOS right now. The composite view controllers that are provided by the framework, such as UINavigationController, and UISplitViewController do a lot of special work to make everything work right for their contained view controllers. Luke On May 18, 2011, at 12:19 PM, Nathan Sims wrote: > Okay, but won't that make for one mega-complex view controller? > > On May 18, 2011, at 11:58 AM, Luke the Hiesterman wrote: > >> The IB concerns aside, attempting to build your own "more than one view >> controller on the screen" solution is currently fraught with peril, and >> something you'll probably get wrong. The window expects to have a single >> rootViewController to handle rotations and such. You're probably better off >> having a single view controller and each of your quad views should just be >> regular UIViews managed by the one view controller. And, if you did that, >> all your views would naturally be built in the one nib that defines your >> view controller :) >> >> Luke >> >> On May 18, 2011, at 11:53 AM, Nathan Sims 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? >>> >>> >>> ___ >>> >>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>> >>> 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: >>> http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com >>> >>> This email sent to luket...@apple.com >> > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
Okay, but won't that make for one mega-complex view controller? On May 18, 2011, at 11:58 AM, Luke the Hiesterman wrote: > The IB concerns aside, attempting to build your own "more than one view > controller on the screen" solution is currently fraught with peril, and > something you'll probably get wrong. The window expects to have a single > rootViewController to handle rotations and such. You're probably better off > having a single view controller and each of your quad views should just be > regular UIViews managed by the one view controller. And, if you did that, all > your views would naturally be built in the one nib that defines your view > controller :) > > Luke > > On May 18, 2011, at 11:53 AM, Nathan Sims 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? >> >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> 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: >> http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com >> >> This email sent to luket...@apple.com > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS: multiple view controllers, one nib?
The IB concerns aside, attempting to build your own "more than one view controller on the screen" solution is currently fraught with peril, and something you'll probably get wrong. The window expects to have a single rootViewController to handle rotations and such. You're probably better off having a single view controller and each of your quad views should just be regular UIViews managed by the one view controller. And, if you did that, all your views would naturally be built in the one nib that defines your view controller :) Luke On May 18, 2011, at 11:53 AM, Nathan Sims 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? > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com > > This email sent to luket...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iOS: multiple view controllers, one nib?
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? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com