作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道我可以做到这一点
[self.navigationController pushViewController:self.someUITabBarController animated:YES];
这意味着以某种方式将 UITabBarController
放在 navigationgController
上
如果我想让 someUITabBarController
成为 navigationController
的第一个 Controller (位于最低级别的那个)怎么办?
我根本无法将 NavigationController
的 rootViewController
更改为 someUITabBarController
最佳答案
嗯,不确定这是你想要的。下面这段代码将放在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
下,在您的“appDelegate”类中。
UITabBarController *tabController = [[UITabBarController alloc] init];
UIViewController *viewController1 = ...
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController1];
NSArray *controllers = [NSArray arrayWithObjects:navigationController, nil]; // can add more if you want
[tabController setViewControllers:controllers];
// this is for custom title and image in the tabBar item
navigationController.tabBarItem.title = @"abc";
[navigationController.tabBarItem setImage:[UIImage imageNamed:@"abc.png"]];
self.window.rootViewController = tabController; // or [self.window addSubview: tabController.view];
[self.window makeKeyAndVisible];
关于iphone - 如何将 TabBarViewController 与 NavigationController 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6366175/
我是一名优秀的程序员,十分优秀!