I built up a Navigation-Based app and I want to implement that functionality in another View-Based app I'm working on.
I figure I can just add a subview with a UINavigati开发者_StackOverflowonContoller and add it to the superview but I cant figure out how to set up the UINavigationController from scratch.
Any ideas on how to basically add a navigation-based app as a subview that can be invoked upon a button tap?
I don't really quite know the context, but you should probably use a Navigation Controller.
In your code you can something to the affect below:
MyViewController *myView = [[MyViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myView];
// Do customisation here
[self.view addSubView:navController]
I'm not quite sure if this is what you want, but you could also consider using a UINavigationController in your App Delegate:
MyViewController *myView = [[MyViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myView];
// Do customisation here
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window addSubview:nav.view];
[window makeKeyAndVisible];
I hope this helps
精彩评论