我有一个loginViewController,并且在成功登录后,我想通过显示具有父标签栏的主屏幕来启动应用程序。
我目前正在使用的流程是:
UITabBarController *arvc = [self.storyboard instantiateViewControllerWithIdentifier:@"homeVC"];
[self presentViewController:arvc animated:YES completion:nil];
但是它没有加载屏幕下方的标签栏。那么如何实现它。
答案 0 :(得分:1)
在storyboard
,从您的loginviewController ctrl+drag
到UITabbarController
,然后从show
中选择popup
。它将从您的登录视图控制器创建新的show
segue到tabbarcontroller。然后点击segue
,然后从attribute inspector
设置identifier
pushToTabbarController
或者您要保留的任何标识符,选择 [self performSegueWithIdentifier:@"pushToTabbarController" sender:nil]; //identifier that you have set in Interface builder
。
现在当你成功登录并想要去tabbbarviewcontroller时,你只需要打电话,
UserId
答案 1 :(得分:0)
MyViewController* vc1 = [[MyViewController alloc] init];
MyOtherViewController* vc2 = [[MyOtherViewController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
tabBarController.viewControllers = controllers;
window.rootViewController = tabBarController;
答案 2 :(得分:0)
使用以下代码成功登录后,您可以浏览应用程序。方法presentViewController
将更新viewcontrollers
的hirachary,当前viewController
将变为rootViewController
..
您必须在故事板上使用identity
向tabBarController
Identity Inspector
提供UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"viewControllerName"];
// this will update viewcontroller stack and vc will become top viewController
[self presentViewController:vc animated:NO completion:nil];
,请参阅图片。
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll