Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top