我试图从mapView中的标注中推送视图。以下代码似乎不起作用。非常感谢任何帮助。
谢谢
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"Tapped Callout");
srPlayAudio *SrPlayAudio = [[srPlayAudio alloc] initWithNibName:@"nib" bundle:nil];
SrPlayAudio.fileName = [[view annotation]title];
[self.navigationController pushViewController:SrPlayAudio animated:YES];
}
每当触摸标注时,控制台都会打印Tapped Callout。我没有看到calloutAccessoryControlTapped方法有任何问题。
答案 0 :(得分:0)
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"Tapped Callout");
srPlayAudio *SrPlayAudio = [[srPlayAudio alloc] init];
SrPlayAudio.fileName = [[view annotation]title];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:SrPlayAudio];
navController.navigationBarHidden = NO;
[self presentViewController:navController animated:YES completion:^{
}];
}
看起来我误解了UINavigationController。 navigationController为null。上面的代码完全正常。