ios:如何使用StoryBoards从ViewController打开Tab Bar控制器 [英] ios: How open Tab Bar controller from ViewController using StoryBoards
问题描述
我这样做,想要从登录页面打开标签栏控制器,如果它已经第一次登录,然后通过登录页面并在Spalsh后打开标签栏控制器
I am doing this and want to open Tab bar Controller from Login Page if its first time and if already login then pass the LoginPage and open Tab Bar Controller after Spalsh
意味着如果用户在应用程序第一时间登陆,则应该像这样
1.启动
2.登录页面
3.成功登录后打开标签栏控制器有4个选项卡
means if user lands in app fiirst time sequesnce should be like this 1. Splash 2. Login Page 3. On successful Login open Tab Bar Controller having 4 tabs
如果用户已登录则
1.启动
2.标签栏控制器
if user already login then 1. Splash 2. Tab bar controller
我正在尝试打开Tab Bar控制器ViewDidLoad方法中的以下代码
I am trying to open Tab Bar controller through the following code in ViewDidLoad method
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屏幕上
and if I remove tbc.selectedIndex=0; it does nothing and stays on Splash screen like this
UITabBarController *lbc = [self.storyboard instantiateViewControllerWithIdentifier:@"TripMapViewer"];
[self presentViewController:lbc animated:YES completion:nil];
请建议我如何从View Controller打开标签栏
please suggest that how do I open tab bar from View Controller
推荐答案
似乎 TripMapViewer 是一些Tab的 Storyboard ID
而不是 UITabBarController
,请确认它可以正常工作
It seems that TripMapViewer is the Storyboard ID
of some Tab and not the UITabBarController
, please make it sure and it will work
,如下面的代码 MainTabBar 故事板ID
UITabBarController
并且它完美运行
as in the below code MainTabBar is Storyboard ID
of UITabBarController
and it works perfectly
UITabBarController *tbc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainTabBar"];
tbc.selectedIndex=0;
[self presentViewController:tbc animated:YES completion:nil];
这篇关于ios:如何使用StoryBoards从ViewController打开Tab Bar控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!