【发布时间】:2013-03-20 18:22:41
【问题描述】:
这段代码可以完美地切换视图控制器,除了标签栏控制器消失了。
现在我尝试了这段代码的许多不同变体
[self presentViewController:homeNavigationController Animation:NO completion: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];
}}
【问题讨论】:
-
你问了很多关于Tab Bars的问题,所有这些似乎都表明对UITabBarController缺乏了解。也许你会很好地阅读它的文档:developer.apple.com/library/ios/#documentation/uikit/reference/… 此外,Apple 甚至提供了一个“旨在展示如何构建基于标签栏的 iOS 应用程序的应用程序”,Tabster:developer.apple.com/library/ios/#samplecode/Tabster/…
标签: iphone ios xcode object tabbar