Question

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.

Was it helpful?

Solution

- (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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top