2

我正在使用故事板,我基本上有这个: 在此处输入图像描述

它是一个 mapView,它以模态方式呈现一个 UINavigationController,其中一个 UIViewController 子类作为它的 contentViewController(位置)。然后,该 LocationViewController 根据表选择(EditLocation)推送另一个 viewController。

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

- (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 回调。想法?谢谢!

4

1 回答 1

0

每当即将发生 segue 时,都会调用 prepareForSegue 方法。我尝试在 MapViewController 的 viewDidLoad 中访问 navigationController(表示选择 tableview 中的任何单元格时加载的 viewController),我得到了正确的描述,如下所示。

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

2012-06-01 12:01:09.986 Sample_Storyboard[1126:207] desc:<UINavigationController: 0x68378e0>
于 2012-06-01T06:44:36.120 回答