我有一個細節披露指標,觸摸時需要帶上MoreDetailViewController堆棧上一個MapView。目前,它崩潰了一個無法識別的選擇器發送到實例錯誤。MapView的註釋崩潰時詳細披露指標觸及
我試圖找出如何調用此方法- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
從披露指標按。
這裏的地圖標註代碼披露指標:
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *mapPin = nil;
if(annotation != map.userLocation)
{
static NSString *defaultPinID = @"defaultPin";
mapPin = (MKPinAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (mapPin == nil)
{
mapPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:defaultPinID];
mapPin.canShowCallout = YES;
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton addTarget:self action:@selector(prepareForSegue:) forControlEvents:UIControlEventTouchUpInside];
mapPin.rightCalloutAccessoryView = disclosureButton;
}
else
mapPin.annotation = annotation;
}
return mapPin;
}
這裏是一個應該被調用的方法:
// Do some customisation of our new view when a table item has been selected
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure we're referring to the correct segue
if ([[segue identifier] isEqualToString:@"ShowMoreInfo"]) {
// Get reference to the destination view controller
MoreDetailViewController *mdvc = [segue destinationViewController];
[mdvc setSelectedItemName:[NSString stringWithFormat:@"%@", placeName.text]];
[mdvc setSelectedItemAddress:[NSString stringWithFormat:@"%@", placeFormattedAddress.text]];
[mdvc setSelectedItemWeb:[NSString stringWithFormat:@"%@", placeWebsite.text]];
[mdvc setSelectedItemRating:[NSString stringWithFormat:@"%@", placeRating.text]];
// [mdvc setSelectedItemDistance:[NSString stringWithFormat:@"%@", placeDistance.text]];
}
}
這裏的錯誤:***終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因是:「 - [DetailViewController prepareForSegue:]:無法識別的選擇發送到實例0x81bbb30」 – hanumanDev