[英]Tab bar disappearing when switching controller
除了標簽欄控制器消失外,此代碼完美地用於切換視圖控制器。
現在我嘗試使用此代碼的許多不同變體
[self presentViewController:homeNavigationController animated: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];
}}
您將以模態方式呈現homeNavigationController - 您所看到的是模態視圖控制器的正常行為,即它們接管整個屏幕,包括標簽欄。 如果要查看標簽欄,請不要使用模式演示文稿。
我解決了這個問題:
1)在AppDelegate中定義YourTabBarController對象
2)來自YourTabBarController對象的presentViewController而不是'self'之類的
[appDelegateObj.yourTabBarObj presentViewController:homeNavigationController animated:NO completion:nil];];
確保您的Appdelegate對象已初始化。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.