マップに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
//....
}