[英]UITabBarController unable to set view
I'm trying to set the view for my UITabBarController to always be the middle item with the following code: 我正在尝试使用以下代码将UITabBarController的视图设置为始终是中间项:
- (void)viewDidLoad
{
[super viewDidLoad];
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
tabBarController.selectedIndex = 2;
}
But it still points towards the first item. 但是它仍然指向第一个项目。 Shouldn't this work? 这不行吗?
inside your UITabBarController call: 在您的UITabBarController调用中:
- (void)viewDidLoad
{
[super viewDidLoad];
self.selectedIndex = 2;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.