2011-11-06 37 views
0

存在问题,我想使用alloutAccessoryControlTapped方法更改viewcontroller。但它不起作用。这里是我的代码:在故事板中更改视图控制器

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

} 

我用故事板来构建视图。这个代码在旧版vison中运行良好。但我想尝试使用故事板。不幸的是,它不起作用。任何人都帮助我?

回答

0

如果您从一个视图控制器创建一个命名的segue到另一个视图控制器并在此处触发,您可能会有更多的运气。我认为这是更多的幕后的东西(你可以手动,但我不知道什么是手头)。

[self performSegueWithIdentifier:@"MyNamedSegue" sender:sender]; 
相关问题