【发布时间】:2015-03-22 12:31:16
【问题描述】:
我有点困惑,无法让事情正常进行。
所以,这是我的应用程序委托中的代码。
// If the device is an iPad, we make it taller.
_tabBarController = [[AKTabBarController alloc] initWithTabBarHeight:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? 70 : 50];
NSString * storyboardName = @"Main_iPhone";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
CurrentViewController * tab1VC = [storyboard instantiateViewControllerWithIdentifier:@"Tab1"];
// dummy controllers
CurrentViewController * tab2VC = [storyboard instantiateViewControllerWithIdentifier:@"Tab1"];
CurrentViewController * tab3VC = [storyboard instantiateViewControllerWithIdentifier:@"Tab1"];
CurrentViewController * tab4VC = [storyboard instantiateViewControllerWithIdentifier:@"Tab1"];
[_tabBarController setViewControllers:[NSMutableArray arrayWithObjects:
tab1VC,
tab2VC,
tab3VC,
tab4VC,
nil]];
[_window setRootViewController:_tabBarController];
[_window makeKeyAndVisible];
然后,在我的故事板中,我有下面的图片:
所以,我有我的 ViewController,然后我点击了 Embed In > Navigation Controller
我想为每个标签使用不同的导航控制器。
在我的 CurrentViewController 中,当单击按钮时我有这个:
- (IBAction)dummyButton:(id)sender {
NSString * storyboardName = @"Main_iPhone";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UserSettingsSetupViewController *userSettingsSetupController = [storyboard instantiateViewControllerWithIdentifier:@"UserSettingsSetup"];
[[self navigationController] pushViewController:userSettingsSetupController animated:YES];
}
显然没有任何东西被推入导航控制器,因为没有任何东西打开。
做了一些研究,我发现这是因为 [self navigationController] 或 self.navigationController 返回 nil。
但这是为什么呢?我应该添加任何代码吗?我认为通过从情节提要中执行此操作,它不应该为零?我错了吗?
【问题讨论】:
标签: ios uinavigationcontroller uitabbarcontroller uitabbar