2012-06-01 49 views
2

我用故事板和我基本上有这样的: enter image description here注册的UINavigationController委托

它的呈现模式地用UIViewController子类作为其contentViewController(位置)一个UINavigationController一个MapView。然后,LocationViewController根据表格选择(EditLocation)推送另一个viewController。

在EditLocation中,我想在调用popViewController时传回信息。我认为我可以使用UINavigationControllerDelegate来做到这一点。所以在Location中,我尝试:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    if ([[segue identifier] isEqualToString:@"ShowEditLocation"]) { 
     UIViewController *destination = segue.destinationViewController; 


     if ([destination respondsToSelector:@selector(setDelegate:)]) { 
      [destination setValue:self forKey:@"delegate"]; 
     } 
    } 
} 

此Location类符合UINavigationControllerDelegate协议。然而,我从来没有从UINavigationController协议获得willShowViewController或didShowViewController回调。思考?谢谢!

回答

0

prepareForSegue方法被调用,每当一个segue即将发生。我试图访问navigationController在viewDidLoad MapViewController(意味着viewController加载时,任何单元格在tableview被选中),我得到了正确的描述如下。

NSLog(@"desc: %@", [[self navigationController] description]); 

2012-06-01 12:01:09.986 Sample_Storyboard[1126:207] desc:<UINavigationController: 0x68378e0> 
相关问题