【问题标题】:presentmodalviewcontroller hides UITabBarpresentmodalviewcontroller 隐藏 UITabBar
【发布时间】:2013-01-09 12:41:35
【问题描述】:

我有一个基本的疑问。我需要将 viewController 推送到另一个 viewController 。 我正在尝试使用代码

Display1 *ac =[[Display1 alloc]init];

[[self navigationController]pushViewController:ac animated:YES];

这提供了导航到上一个堆栈的选项。 我没有选择继续上一个堆栈。因此我尝试了presentModalViewController

Display1 *ac =[[Display1 alloc]init];

[self presentModalViewController:ac animated:YES];

但这很好用,这个没有给我选项,但 presentModalViewController 隐藏我的 UITabBarController

.无论如何,用 presentModalViewController 显示 UITabBarController。 或使用 pushViewController 不显示上一个堆栈

【问题讨论】:

  • 使用这个:self.navigationItem.hidesBackButton = YES;

标签: iphone ios uinavigationcontroller uitabbarcontroller presentmodalviewcontroller


【解决方案1】:

Darshana 是对的,如果您不想使用返回选项

self.navigationItem.hidesBackButton = YES;

之前

[[self navigationController]pushViewController:ac animated:YES];

但是如果你想在新的 UIViewController 上使用 UITabBar,那么你必须像这样添加那个控制器:

NextViewController *nextViewController=[[NextViewController alloc]initWithNibName:@"NextViewController" bundle:nil];
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:nextViewController];
[self.navigationController presentModalViewController:navBar animated:YES];

我是从PresentModalViewController not showing navigation bar on next view那里得到的

但首先要确定要使用 PUSH 还是 MODAL。
这两者有不同的目的。

【讨论】: