【问题标题】:how to push views iphone?iphone如何推送意见?
【发布时间】:2011-08-07 19:07:41
【问题描述】:

我是 iphone 开发的新手,我需要一些指导来推送视图。我有以下应用场景“按下按钮->切换视图(包含表格)->按下表格单元格->切换视图”。

要在按下按钮时切换,我使用以下代码:

MapView *screen = [[MapView alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:screen animated:YES];
[screen release];

然后推送另一个视图,我想使用此代码(但它不起作用 - 我问为什么?)

Newclass *nextController = [[Newclass alloc] initWithItem:theItem];
    [self.navigationController pushViewController:nextController animated:YES];
    [nextController release];

【问题讨论】:

  • 你正在使用 self.navigationController 我猜你的 mapview 没有导航控制器

标签: ios objective-c iphone uiviewcontroller xib


【解决方案1】:

您想从您的 MapView 推送此视图吗?看起来您没有推送此类视图控制器所需的 UINavigationController。

更新您的代码的第一部分,将 MapView 放入 UINavigationController,然后您可以使用您拥有的代码的第二部分将其他视图推送到它上面。

MapView *screen = [[MapView alloc] initWithNibName:nil bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:screen]; // this puts the MapView onto navigation controller
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; // you will present the navController instead of screen so change it's modalTransitionStyle
[self presentModalViewController:navController animated:YES]; // present it
[screen release];
[navController release]; // don't forget to release

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-18
    • 1970-01-01
    • 2011-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多