简体   繁体   中英

change viewcontroller in the storyboard

there is problem, I want use alloutAccessoryControlTapped method to change viewcontroller. but it doesn't works. here is my code:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    NSLog(@"calloutAccessoryControlTapped");
    Restaurant *location = [view annotation];


//    RestaurantDetail *resdetail = [[RestaurantDetail alloc] init];
    RestaurantDetail *resdetail = [self.storyboard instantiateViewControllerWithIdentifier:@"details"];
    [resdetail setLocation:location];
    [self.view addSubview:resdetail.view];

}

I used storyboard to build the view. this code runs well in old vison. but I want try to use storyboard. unfortunately, it doesn't work. anyone help me?

You might have more luck if you create a named segue from one viewcontroller to the other and trigger it here. I think that does more behind-the-scenes stuff (that you could do manually, but I don't know what all that is off-hand).

[self performSegueWithIdentifier:@"MyNamedSegue" sender:sender];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM