简体   繁体   English

导航控制器到选项卡栏控制器

[英]Navigation controller to tab bar controller

I am storyboarding my app. 我正在对我的应用进行情节提要。 The structure of the app is a login screen without a navigation bar or a tab bar which leads into the app showing navigation bar and tab bar on all screens. 该应用程序的结构是不带导航栏或标签栏的登录屏幕,该登录屏幕通向应用程序,并在所有屏幕上显示导航栏和标签栏。 So a navigation controller leading into a tab bar controller. 因此,导航控制器通向标签栏控制器。

I have tried the following when log in is successful: 登录成功后,我尝试了以下方法:

UITabBarController *tabBarController=[[UITabBarController alloc]init];

DiaryViewController *diaryViewController = (DiaryViewController *)[storyboard instantiateViewControllerWithIdentifier:@"diary"];
WhosOutViewController *WOutViewController = (WhosOutViewController *)[storyboard instantiateViewControllerWithIdentifier:@"WhoOut"];
WhatsNearViewController *whatsNearViewController = (WhatsNearViewController *)[storyboard instantiateViewControllerWithIdentifier:@"WhatsNear"];
MoreViewController *moreViewController = (MoreViewController *)[storyboard instantiateViewControllerWithIdentifier:@"More"];
tabBarController.viewControllers=[NSArray arrayWithObjects:diaryViewController,whatsNearViewController, WOutViewController, moreViewController, nil];

[self.navigationController pushViewController:tabBarController animated:YES];

It does push with showing a tab bar but the navigation bar doesn't display. 它确实会推送并显示一个标签栏,但不会显示导航栏。 Can someone help me with this please? 有人可以帮我吗? Or please suggest another way to implement this. 或者,请提出另一种实现此方法的方法。

Thanks in advance 提前致谢

Suggestion .You should do the other way round: 建议 。您应该反过来做:

self.navigationControllerOne.viewControllers = [NSArray arrayWithObject:diaryViewController];
self.navigationControllerTwo.viewControllers = [NSArray arrayWithObject:whatsNearViewController];
...
tabBarController.viewControllers=[NSArray arrayWithObjects:self.navigationControllerOne ,self.navigationControllerTwo, ... , nil];

and then push/dismiss happily 然后愉快地推动/关闭

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM