我认为我的代码有问题,但我找不到。
我想通过单击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