0
我想我的代碼有問題,但我找不到它。canShowCallout按鈕不起作用
我想與在leftCalloutAccessoryView
按鈕,一個單一的點擊切換視圖,但我得到總是相同的錯誤:
NSInvalidArgumentException', reason: '
-[ThirdViewController showDetailView:]: unrecognized selector sent to instance
這裏我的代碼:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
return nil;
}
else
{
MKPinAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"loc"];
annotationView.canShowCallout = YES;
UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[detailButton addTarget:self action:@selector(showDetailView:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView=detailButton;
annotationView.enabled = YES;
UIImage *image = [UIImage imageNamed:@"logo.jpeg"];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
annotationView.leftCalloutAccessoryView = imgView;
annotationView.image = [UIImage imageNamed:@"pin.png"];
return annotationView;
}
}
- (IBAction)detailButton:(UIButton *)sender
{
ThirdViewController *infoView = [[ThirdViewController alloc] init];
[self.navigationController pushViewController:infoView animated:YES];
NSLog(@"pushed Button!!!!!!");
}
從我的故事板的小截圖:
感謝您的幫助!
問候CTS