簡體   English   中英

Unin Segue for UINavigationController

[英]Unwind Segue for UINavigationController

我有一個簡單的UINavigationController,它通過自定義segue將UIViewController推送到堆棧。 然后我在第一個UIViewController上實現了一個IBAction來執行一個展開動作,我實現了segueForUnwindingToViewController。 不幸的是,沒有調用segueForUnwindingToViewController(我確實確認在第一個VC上調用了canPerformUnwindSegue)。

我還沒有看到任何這種行為的簡單例子。 有人可以幫忙嗎? 謝謝。

這是NavigationController的根視圖控制器中的代碼。

- (IBAction) unwindFromSegue:(UIStoryboardSegue *)segue {
// unwinds back to here
//[self performSegueWithIdentifier:@"UnwindToObjectManageSegue" sender:self];

}

- (BOOL)canPerformUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController
                     withSender:(id)sender {
return YES;
}

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
return YES;
}

- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController
                                  fromViewController:(UIViewController *)fromViewController
                                          identifier:(NSString *)identifier {
ObjectManageObjectDetailSegue *segue = [[ObjectManageObjectDetailSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController];
[segue setUnwinding:YES];
return segue;
}

我有同樣的問題,我終於找到了解決方案: https//github.com/simonmaddox/CustomUnwindSegue

他也有一個問題,沒有被召喚。 事實證明,UINavigationController中的任何視圖控制器都不會調用呈現視圖控制器而是調用UINavigationController。 這意味着您必須子類化UINavigationController並在那里添加該方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM