gpt4 book ai didi

ios:如何使用 StoryBoards 从 ViewController 打开 Tab Bar Controller

转载 作者:可可西里 更新时间:2023-11-01 03:25:29 25 4
gpt4 key购买 nike

我正在这样做,如果是第一次,我想从登录页面打开标签栏 Controller ,如果已经登录,则在 Spalsh 之后传递登录页面并打开标签栏 Controller

意味着如果用户第一次登陆应用程序,时间序列应该是这样的1. 飞溅2.登录页面3. 成功登录后打开有 4 个选项卡的 Tab Bar Controller

如果用户已经登录1. 飞溅2.标签栏 Controller

enter image description here

我正在尝试通过 ViewDidLoad 方法中的以下代码打开 Tab Bar Controller

UITabBarController *tbc = [self.storyboard instantiateViewControllerWithIdentifier:@"TripMapViewer"];
tbc.selectedIndex=0;
[self presentViewController:tbc animated:YES completion:nil];

但是报错

2014-02-06 19:55:43.849 ProjNew[1065:907] -[TripMapViewer setSelectedIndex:]: 无法识别的选择器发送到实例 0x1d5600b0

如果我删除 tbc.selectedIndex=0; 它什么都不做并且像这样停留在初始屏幕上

UITabBarController *lbc = [self.storyboard instantiateViewControllerWithIdentifier:@"TripMapViewer"];
[self presentViewController:lbc animated:YES completion:nil];

请建议我如何从 View Controller 打开标签栏

最佳答案

似乎 TripMapViewer 是某个 Tab 的 Storyboard ID 而不是 UITabBarController ,请确保它会起作用

在下面的代码中 MainTabBarUITabBarControllerStoryboard ID 并且它完美地工作

UITabBarController *tbc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainTabBar"];
tbc.selectedIndex=0;
[self presentViewController:tbc animated:YES completion:nil];

关于ios:如何使用 StoryBoards 从 ViewController 打开 Tab Bar Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21606715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com