【发布时间】:2014-03-31 08:19:24
【问题描述】:
我在 UITabBarViewController 中有四个选项卡。每个视图的导航栏都添加了 UIButton,每个选项卡都有一个“发布按钮”,可以将用户带到发布页面。
如何引用已经位于我的故事板中的 ViewController,以便我可以将其传递给 PresentViewController: 方法?
例如,这是从四个标签栏视图中的任何一个单击发布按钮时使用的方法:
- (void)postInvoked:(UIBarButtonItem *)sender
{
[self presentViewController:______ animated:YES completion:nil];
}
空白处是什么?我想我需要避免像这样引用 UIViewController:
UIViewController * postPage = [[UIViewController alloc] init];
因为这会在用户每次导航到页面时创建一个新的页面实例。
【问题讨论】:
-
您是否需要每次都转到同一个实例(该控制器中是否有您希望在从不同选项卡呈现数据之间保留的数据)?
-
为您的 viewController 设置 storyBoardId,然后使用“instantiateViewControllerWithIdentifier”进行展示或推送。
标签: ios objective-c xcode