I’m attempting to write a multiview app in iOS and really having a bit of a tough time… I’ve setup a new project and I’ve got a rootViewController being launched by the appDelegate. In turn, the rootViewController attempts to load and display my first content view, although I seem to have fallen into some kind of infinite loop, I’m hoping someone here may have a hunch as to why…
-(void)viewDidLoad
{
// Load up new instance of view
TopLevelViewController *topLevelController =
[[TopLevelViewController alloc] initWithNibName:@"TopLevelView" bundle:nil];
// Hand off viewController reference to root controller
self.topLevelViewController = topLevelController;
// Display the view
[self.view insertSubview:topLevelController.view atIndex:0];
// Release viewController
[topLevelController release];
[super viewDidLoad];
}
Above is my rootViewController viewDidLoad: method, although every time it executes insertSubview, it seems to return to the top and perform the whole thing again. I’m a bit confused as I’ve based this code almost identically on a tutorial I followed and it ran beautifully…which leads me to think the problem must be elsewhere, although I couldn’t possibly think where.
Appreciate any insight!
Just realized I had never closed this after the recent interest.
As I remember, @Wolfgang Schreurs is exactly correct. For whatever reason, while experimenting with the code, I had
topLevelViewControllerinherit fromrootViewController.Hopefully this helps anyone else who may run into the same issue.