私はストーリーボードを使用していますが、基本的にこれがあります。
これは、UIViewControllerサブクラスをcontentViewController(Location)として持つUINavigationControllerをモーダルに表示するmapViewです。次に、その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コールバックを取得することはありません。考え?ありがとう!