这段代码可以完美地切换视图控制器,除了标签栏控制器消失了。
现在我尝试了此代码的许多不同变体
[self presentViewController:homeNavigationController 动画:没有完成:nil];
但它们似乎都不能正常工作。推送控制器只是将视图冻结到位。关于做什么的任何提示?
- (void)_tabBarItemClicked:(id)item {
assert([item isKindOfClass:[UIButton class]]);
NSInteger selectedIndex = ((UIButton *)item).tag;
[self setSelectedIndex:selectedIndex];
[self _setSelectedItemAtIndex:selectedIndex];
NSDictionary *userInfo = @{@"index": [NSNumber numberWithInt:selectedIndex]};
[[NSNotificationCenter defaultCenter] postNotificationName:@"tabBarDidSelectItem" object:nil userInfo:userInfo];
if (selectedIndex ==2) {
HomeViewController *homeViewController = [[HomeViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
[self presentViewController:homeNavigationController animated:NO completion:nil];
}}