문제

I'm trying to push a view from a callout in my mapView. The following code does not seem to work. Any help is immensely appreciated.

Thank You

- (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];
}

The console prints Tapped Callout whenever the callout is touched.I don't see any problem with the calloutAccessoryControlTapped method.

도움이 되었습니까?

해결책

- (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:^{

}];

}

Looks like I misunderstood UINavigationController. navigationController was null. The code above works completely fine.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top