创建一个UIViewController

时间:2012-09-11 12:16:16

标签: objective-c uiview uinavigationcontroller

我有一个名为Map:

的文件
@interface Map : UIViewController<MKMapViewDelegate> {
    IBOutlet MKMapView *map;
}    

在界面中,单击选项卡时,界面将启动:

enter image description here

Map在点击时会打开一个UITableViewController,这个UITableView会打开另一个UITableViewController。

所以我现在想要的是在最后一个UITableViewController中,当按下后退按钮时,回到地图。我永远不会改变标签,我总是在“Plano”

所以,在Navigation.m中我有:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization

}
return self;
}

在我的secondUITableView.m中:

Navigation *aMap = [[Navigation alloc]initWithNibName:@"Map" bundle:nil];
[self.navigationController popToViewController:aMap animated:YES];

错误是什么:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'

我该怎么做?

提前谢谢

1 个答案:

答案 0 :(得分:1)

编辑

对于后根

[self.navigationController popToRootViewControllerAnimated:YES];

返回

[self.navigationController popViewControllerAnimated:YES];