我实际上试图在函数didSelectRowAtIndexPath中显示类型为UIViewController的新控制器MKMapViewDelegate 。 我在控制器中有一个tableview,当我点击这个tableview的单元格时,我想显示类型为UIViewController MKMapViewDelegate的新控制器。使用函数didSelectRowAtIndexPath显示地图
我的代码如下:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
UIViewController *mapviewtest=[[MapStation alloc]initWithNibName:@"MapStation" bundle:nil];
[self.navigationController pushViewController:mapviewtest animated:YES];
//Station *station = nil;
//station = [self.listStation objectAtIndex:indexPath.row];
}
的问题是,当我在程序退出就行断点的实现代码如下的任意单元格点击:
UIViewController *mapviewtest=[[MapStation alloc]initWithNibName:@"MapStation" bundle:nil];
我不知道它为什么这样做以及如何解决这个错误。也许你知道另一种方式来做到这一点(不使用pushviewController函数)。
等待您的回答家伙;-)
真诚
昆汀
和梅普斯塔申是的UIViewController的一个子类? – 2012-03-16 16:40:50
是的MapStation是UIViewController的子视图。我想这可能来自我的navigationController.I没有创建一个(因为它是在控制器被调用时创建的,是不是?) – Quentin91360 2012-03-16 16:51:25
navController不是为你创建的。如果你没有navController,当你尝试推送时,没有任何反应。没有崩溃。如果我不得不猜测,我会说你在执行'initWithNibName:bundle:'时有一个错误,或者你的xib中有一个连接到.h文件中不存在的插座的对象。但我没有心情去猜测。检查控制台输出。 – 2012-03-16 17:26:32