我在地圖上的一些annotationView,我想與touchUpInside打開一個新的視圖控制器,但我得到這個錯誤:「NSInvalidArgumentException」的
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
//....
}
非常感謝 –