[英]How within a tab bar controller do I segue from one view controller to another and retain the tab bar?
I have an application with several view controllers controlled from a tab bar controller. 我有一个应用程序,其中有几个视图控制器由标签栏控制器控制。 From one of these view controllers I want to (on clicking a button) segue to another view controller and retain the tab bar at the bottom of the segued to view. 从我想要的其中一个视图控制器(在单击按钮上)转到另一个视图控制器并保留要查看的segued底部的标签栏。
I've used 我用过
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"newView"]){
UIViewController *controller =segue.destinationViewController;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
}
This works fine except the tab bar is missing from the segued to view (a placeholder shows for it in the storyboard, but it doesn't show up when the app is run) I've also tried replacing 这样工作正常,除了从视图到视图中缺少标签栏(占位符在故事板中显示它,但在应用程序运行时它不会显示)我也尝试过更换
[self presentModalViewController:controller animated:YES];
with 同
[self presentViewController:controller animated:YES completion:nil];
but that doesn't work either. 但这也不起作用。
A bit of debugging shows that for the segued-to view controller, the tabBarController property is set to nil. 一些调试显示,对于segued-to视图控制器,tabBarController属性设置为nil。
Is there anyway to retain the tab bar in the segued-to view controller? 反正有没有保留标签栏在segued-to视图控制器?
From your explanation, I don't think you want a modal controller. 根据你的解释,我不认为你想要一个模态控制器。 Modal is used to overlay, rendering your tab bar useless. 模态用于叠加,使标签栏无效。 From your storyboard, select your segue and select push, not modal. 从故事板中,选择您的segue并选择推送,而不是模态。
Push vs Modal (Note the tab bar): Push vs Modal(注意标签栏):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.