简体   繁体   English

在选项卡栏控制器中选择时以模态显示视图控制器

[英]Present a View Controller modally when selected in Tab Bar Controller

I have this pretty standard Tab Bar Controller setup: 我有这个非常标准的标签栏控制器设置:

UIViewController *homeViewController = [[PLOTHomeViewController alloc] init];
UIViewController *upcomingViewController = [[PLOTUpcomingViewController alloc] init];
UIViewController *checkInViewController = [[PLOTCheckInViewController alloc] init];
UIViewController *watchlistViewController = [[PLOTWatchlistViewController alloc] init];
UIViewController *profileViewController = [[PLOTProfileViewController alloc] init];

PLOTNavigationController *homeNavVC = [[PLOTNavigationController alloc] initWithRootViewController:homeViewController];
PLOTNavigationController *upcomingNavVC = [[PLOTNavigationController alloc] initWithRootViewController:upcomingViewController];
PLOTNavigationController *checkInNavVC = [[PLOTNavigationController alloc] initWithRootViewController:checkInViewController];
PLOTNavigationController *watchlistNavVC = [[PLOTNavigationController alloc] initWithRootViewController:watchlistViewController];
PLOTNavigationController *profileNavVC = [[PLOTNavigationController alloc] initWithRootViewController:profileViewController];

self.tabBarController = [[PLOTTabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:homeNavVC, upcomingNavVC, checkInNavVC, watchlistNavVC, profileNavVC, nil];

However, I'm trying to work out how, when the user selects the middle tab (checkInViewController), I can present that View Controller modally (fullscreen)? 但是,我试图找出如何在用户选择中间选项卡(checkInViewController)时以模态方式(全屏显示)显示View Controller? I'd maybe imagine something in the viewDidAppear method in that VC, but I'm not sure if you can present yourself modally, if you're a VC? 我可能会想象该VC的viewDidAppear方法中有什么问题,但是我不确定如果您是VC,是否可以模态呈现自己? What's the best approach for this? 最好的方法是什么?

You can use 您可以使用

[self presentViewController:checkInViewController animated:YES completion:nil];

Then hide the tab and navigation bars in the destination view controller's viewWillAppear: 然后在目标视图控制器的viewWillAppear:隐藏选项卡和导航栏viewWillAppear:

-(void)viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    [self.tabBarController.tabBar setHidden:YES];
}

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

相关问题 从标签栏控制器以模态方式呈现视图 - Present a View modally from a tab bar controller 从选项卡栏控制器以模态方式呈现视图控制器 - Present a View Controller modally from a tab bar controller 当视图 Controller 嵌入导航 Controller 时,以模态方式显示选项卡栏视图? - Present a Tab Bar View Modally when View Controller is embedded in a Navigation Controller? 如何在选项卡栏项目上轻按以方式显示View Controller - How to modally present a View Controller on tap of tab bar item 嵌入在导航控制器中的当前View Controller(以选项卡栏控制器的形式) - Present View Controller embedded in Navigation Controller apart of Tab bar controller modally Swift:轻按Tab栏时关闭模态呈现的视图控制器 - Swift: Dismissing Modally Presented View Controller when Tab Bar is tapped 如何不显示查看 Controller 模态 - How to not present View Controller Modally 关闭以模态显示的视图使标签栏控制器(种类)重置 - Dismiss Modally presented view makes tab bar controller (kind of) reset 当我以模态方式呈现特定的视图控制器时,如何在视图控制器上制作熟悉的外观状态栏? - How do i make a familiar looking status bar on a view controller when i present a particular view controller modally? 在选项卡栏控制器之前显示视图 - Present a View before Tab Bar Controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM