gpt4 book ai didi

ios - 如何处理需要使用 navigationController 的 tabBar 内的 presentModal

转载 作者:行者123 更新时间:2023-11-29 10:56:11 24 4
gpt4 key购买 nike

我试图将 View Controller 推送到 presentmodal 中,但没有任何反应。因此,我有一个 loginController 作为 rootViewController,它推送一个 tabBarControler,然后在其中一个 tabBar View 中打开一个 presentModal。在 presentModal 中,单击时我有一个 UITableView 推送另一个 View ,但是当我尝试执行此操作时,什么也没有发生。为了更清楚这里的层次结构:

LoginViewController(as root view controller) >>>push>>> UITabBarController(HomeViewController and two others) >>>open>>> PackViewController(presentModal) 需要通过pushViewController打开另一个 View :

代码:

AppDelegate.m

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

LoginViewController_iPhone *loginViewController = [[LoginViewController_iPhone alloc] init];

self.navigationController = [[[UINavigationController alloc] initWithRootViewController:loginViewController] autorelease];

self.window.rootViewController = self.navigationController;

登录 View Controller .m

- (void)viewDidLoad
{
[super viewDidLoad];

HomeViewController_iPhone *referenciaHomeViewController = [[HomeViewController_iPhone alloc] init];
MapaViewController_iPhone *referenciaMapaViewController = [[MapaViewController_iPhone alloc] init];
GuiaViewController_iPhone *referenciaMidiaViewController = [[GuiaViewController_iPhone alloc] init];

UINavigationController *navHome = [[UINavigationController alloc] initWithRootViewController:referenciaHomeViewController];
UINavigationController *navMapa = [[UINavigationController alloc] initWithRootViewController:referenciaMapaViewController];
UINavigationController *navGuia = [[UINavigationController alloc] initWithRootViewController:referenciaMidiaViewController];

self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"tabBarBackground"]];
[self.tabBarController.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"tabBarSelected"]];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navHome, navMapa, navGuia, nil];

}

- (void)login {

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

}

PackViewController.m(当前模式):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[tableView deselectRowAtIndexPath:indexPath animated:YES];

CompraPackViewController_iPhone *controller = [[CompraPackViewController_iPhone alloc] init];

[self.navigationController pushViewController:controller animated:YES];
[controller release];

}

最佳答案

当你做你的 present modal 时,你需要展示一个导航 Controller ,它的 Root View Controller 是 TableView Controller 。

关于ios - 如何处理需要使用 navigationController 的 tabBar 内的 presentModal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18296048/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com