I want to know that how can we setup a UIViewController in a UINavigationController without using UITableView to its Root View Controller. Any help regarding this? Thanks in advance.
You can do that as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
UIViewController *myViewController = [[UIViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
self.window.rootViewController = navigationController;
// ...
}
You can replace the class of myViewController
and/or initialize it using a nib if you want.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:[[OptionViewController alloc]initWithNibName:@"OptionViewController" bundle:nil]];
self.window.rootViewController=nav;
self.window.backgroundColor = [UIColor grayColor];
[self.window makeKeyAndVisible];
return YES;
}
It's working for me:
set your tabviewcontroller on window, then it will work properly.
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UITabBarController *tabVC = [self.storyboard instantiateViewControllerWithIdentifier:@"MyMainView"];
[window setRootViewController:tabVC];
UINavigationController pushViewController:动画化:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.