我在地图中有一些 annotationView,我想用 touchUpInside 打开一个新的 ViewController 但我收到了这个错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
[MapViewController loadDetailListViewController:]: unrecognized selector sent
to instance 0xa042380'
这是 MapViewController.m 中的代码:
-(void)loadDetailListViewController{
if(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone){
DetailListViewController *detailList =[[DetailListViewController
alloc]initWithNibName:@"DetailListViewController~iPhone" bundle:nil];
detailList.title = self.chinaTable.title;
detailList.chinaTable = self.chinaTable;
[self.navigationController pushViewController:detailList animated:YES];
}else {
DetailListViewController *detailList =[[DetailListViewController
alloc]initWithNibName:@"DetailListViewController~iPad" bundle:nil];
detailList.title = self.chinaTable.title;
detailList.chinaTable = self.chinaTable;
[self.navigationController pushViewController:detailList animated:YES];
}
}
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id
<MKAnnotation>)annotation {
//......
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action:@selector(loadDetailListViewController:)
forControlEvents:UIControlEventTouchUpInside]; //the error is here
//....
}