Reputation: 4994
I have created a custom navigation controller in appDelegate :
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
poemsView = [[[PoemsViewController alloc]initWithNibName:@"PoemsViewController" bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:poemsView] autorelease];
self.navigationController.navigationBarHidden = YES;
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
so the problem is I need my app lunches from viewController , but if I set my viewController as rootviewController , my navigation controller does not push navigation and vice versa , if set my navigation controller as a root , app does not load from menus or main view controller .
Upvotes: 0
Views: 1437
Reputation: 4789
Why you Creating Poemsview as rootviewcontroller of Navigation Controller ?
if You Want To Load ViewController First Then use the following Code.
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
poemsView = [[[PoemsViewController alloc]initWithNibName:@"PoemsViewController" bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
self.navigationController.navigationBarHidden = YES;
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
You Can Create Another Navigation Controller as a Sub-class of Viewcontroller.
In your Poem Button Action Add The Following :
// Create a regular view controller.
PoemViewController *modalViewController = [[[PoemViewController alloc] initWithNibName:@"PoemViewController" bundle:nil] autorelease];
// Create a navigation controller containing the view controller.
UINavigationController *secondNavigationController = [[UINavigationController alloc] initWithRootViewController:modalViewController];
// Present the navigation controller as a modal view controller on top of an existing navigation controller
[self presentModalViewController:secondNavigationController animated:YES];
Now You can be able push To detail View from Your tableview DidselectRowAtindexpath
.
Upvotes: 1