I want to Use Both Tab Bar And Navigation Bar in Same View Controller

戏子无情 提交于 2019-12-25 04:09:51

问题


I had Take ViewController And Put Navigation Controller from Object Library than Put Tab Bar Same As Navigation Controller.... But Tab Bar Can't Show In Controller...


回答1:


First declare your tab bar controller in your delegate .h file

@property (strong, nonatomic) UITabBarController *tabBarController; 

then declare your root view controller and add it to navigation controller in .m file

UIViewController *homeViewController = [[[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil] autorelease];
    UINavigationController *navigationcontroller = [[[UINavigationController alloc] initWithRootViewController:homeViewController] autorelease];

then add the array of controllers to tab bar

self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationcontroller,secondViewController and so on, nil];


来源:https://stackoverflow.com/questions/10229805/i-want-to-use-both-tab-bar-and-navigation-bar-in-same-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!