1

我正在尝试将视图控制器推入当前模式,但没有任何反应。所以,我有一个作为 rootViewController 的 loginController,它推送一个 tabBarControler,然后在其中一个 tabBar 视图中打开一个 presentModal。在 presentModal 我有一个 UITableView 单击推送另一个视图但是当我尝试这样做时没有任何反应。为了更清楚,这里的层次结构:

LoginViewController(作为根视图控制器)>>>push>>> UITabBarController(HomeViewController 和其他两个)>>>打开>>> PackViewController(presentModal)需要通过pushViewController打开另一个视图:

编码:

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;

登录视图控制器.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 (PRESENTMODAL):

- (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];

}
4

1 回答 1

2

当您执行当前模式时,您需要呈现一个导航控制器,其根视图控制器是表视图控制器。

于 2013-08-18T05:51:26.747 回答