ios:如何使用StoryBoards从ViewController打开Tab Bar控制器

我这样做,想要从登录页面打开标签栏控制器,如果它已经第一次登录然后通过登录页面并在Spalsh后打开标签栏控制器

意味着如果用户在第一时间登陆应该是这样的
飞溅
2.登录页面
3.成功登录后打开标签栏控制器,有4个标签

如果用户已经登录
飞溅
2.标签栏控制器

我试图通过ViewDidLoad方法中的以下代码打开Tab Bar控制器

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;它什么都不做,就像这样停留在Splash屏幕上

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

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

解决方法

看来TripMapViewer是某些Tab的Storyboard ID,而不是UITabBarController,请确保它确实有效

如下面的代码MainTabBar是UITabBarController的Storyboard ID,它完美地运行

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

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...