2011-11-06 40 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]; 
相關問題