iPhone以编程方式选择Tab并推送视图控制器
使用 Facebook 的新 SSO,登录 Facebook 意味着我的应用程序暂时关闭。问题是我的应用程序要求规定它不能在后台运行。因此,当我的应用程序重新启动时,它位于原始选项卡/视图控制器上。
我正在尝试将事情恢复到 Facebook 登录视图。这需要以编程方式选择一个选项卡并从该选项卡推送到单独的视图控制器。
我可以以编程方式选择一个选项卡,没有问题:
[[UIApplication sharedDelegate].tabBarController setSelectedIndex:4];
但我无法从新选择的选项卡中推送视图控制器。我已经尝试过了
AboutViewController *nextViewController = [[AboutViewController alloc] initWithStyle:UITableViewStyleGrouped];
((AboutViewController *)nextViewController).hidesBottomBarWhenPushed = NO;
[[[[[UIApplication sharedDelegate] tabBarController] selectedViewController ] navigationController] pushViewController:nextViewController animated:NO];
[nextViewController release];
,
AboutViewController *nextViewController = [[AboutViewController alloc] initWithStyle:UITableViewStyleGrouped];
((AboutViewController *)nextViewController).hidesBottomBarWhenPushed = NO;
[[[[[UIApplication sharedDelegate] tabBarController] navigationController] pushViewController:nextViewController animated:NO];
[nextViewController release];
是否有可能做到这一点?
With Facebook's new SSO, logging into Facebook means that my app is temporarily shut down. The problem is that my app requirements dictate that it cannot run in the background. So, when my app is brought back up, it is on the original tab/view controller.
I am trying to get things back to the facebook login view. This requires programmatically selecting a tab AND pushing from that tab to a separate view controller.
I can programmatically select a tab no problem:
[[UIApplication sharedDelegate].tabBarController setSelectedIndex:4];
But I cannot push the view controller from the newly selected tab. I've tried
AboutViewController *nextViewController = [[AboutViewController alloc] initWithStyle:UITableViewStyleGrouped];
((AboutViewController *)nextViewController).hidesBottomBarWhenPushed = NO;
[[[[[UIApplication sharedDelegate] tabBarController] selectedViewController ] navigationController] pushViewController:nextViewController animated:NO];
[nextViewController release];
and
AboutViewController *nextViewController = [[AboutViewController alloc] initWithStyle:UITableViewStyleGrouped];
((AboutViewController *)nextViewController).hidesBottomBarWhenPushed = NO;
[[[[[UIApplication sharedDelegate] tabBarController] navigationController] pushViewController:nextViewController animated:NO];
[nextViewController release];
Is it even possible to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
try this:
如果有人需要的话,这里有一个 Swift 解决方案:
在我的例子中,必须从选项卡 2 中的嵌套视图控制器到达选项卡 4 中的另一个嵌套视图控制器。
Here is a
Swift
solution if anyone needs it:In my case, had to get from a nested viewController in tab 2 to another nested view controller in tab 4.