Dismiss pushed view from within Navigation Controller

后端 未结 6 1398
北恋
北恋 2021-02-01 04:40

I have a Navigation Controller with a View Controller displaying a button. The button is linked to another View Controller using a push segue which automatically adds a top navi

相关标签:
6条回答
  • 2021-02-01 05:17

    In Swift it would be calling the method

    self.navigationController?.popViewControllerAnimated(true)
    
    0 讨论(0)
  • 2021-02-01 05:19

    Obtain a reference to your UINavigationController and call

    - (UIViewController *)popViewControllerAnimated:(BOOL)animated
    

    on it.

    0 讨论(0)
  • 2021-02-01 05:19

    In swift you can also call:

    self.navigationController?.popToRootViewControllerAnimated(true)
    
    0 讨论(0)
  • 2021-02-01 05:19

    If NavViewController is used with UIModalPresentationFullScreen then the below line will work

    self.navigationController?.dismiss(animated: true, completion: nil)
    
    0 讨论(0)
  • 2021-02-01 05:23

    If we use push segue, then use popViewController

    @IBAction func backButtonClicked(_ sender: Any) {
        self.navigationController?.popViewController(animated: false)
    }
    
    0 讨论(0)
  • 2021-02-01 05:39

    On Objective-C is

    [self.navigationController popViewControllerAnimated:YES];
    

    for a jump to the first root controller

    [self.navigationController popToRootViewControllerAnimated:YES];
    

    or is a possible move to the specific controller

    [self.navigationController popToViewController:(nonnull UIViewController *) animated:(BOOL)];
    

    animation specific animation process of move the controller. If the animation is false the controller will appear without animations. The UIViewController must be from one which is on the stack.

    0 讨论(0)
提交回复
热议问题