【发布时间】:2014-09-29 01:47:07
【问题描述】:
我有三个标签,即Message、Contact 和More。每个选项卡都是一个 UINavigationController。在Contact 选项卡中,我们可以通过添加一些朋友来创建群聊。单击Create 按钮后,视图将导航到Message 选项卡中的新视图控制器。但是,Message 和Contact 选项卡中的导航控制器是不同的;因为它们是平行的。所以我需要你的帮助,告诉我如何实现这样的功能。
这是我的代码片段,但它不起作用,只返回到 Message 的根视图,而不是 testvc 视图控制器。
- (IBAction)createGroupButtonPressed:(UIButton *)sender {
UIStoryboard *storyboard = [self storyboard];
UIViewController *testvc = [storyboard instantiateViewControllerWithIdentifier:@"testvc"];
UIViewController *messageTab = [storyboard instantiateViewControllerWithIdentifier:@"messageTab"];
[self.navigationController popToRootViewControllerAnimated:YES];
[self.tabBarController setSelectedIndex:0];
[messageTab.navigationController pushViewController:testvc animated:YES];
}
谢谢。
【问题讨论】:
-
切换标签到“消息标签”时,延迟1秒推送“testvc”视图控制器。我不知道它是否有效,但先尝试。
-
@liaogang 如何延迟1秒?你的意思是让线程休眠一秒钟?它会阻止应用程序吗?谢谢。
-
@liaogang 我尝试使用
dispatch_after将[messageTab.navigationController pushViewController:testvc animated:YES];延迟1秒,但它不起作用。 -
你说每个标签都是一个 UINavigationController。那么
UIViewController * messageTab应该是UINavigationController *messageTab? -
@liaogang 是的。
标签: ios objective-c iphone uinavigationcontroller