Calling popViewControllerAnimated twice

前端 未结 4 1375
臣服心动
臣服心动 2021-01-30 11:26

I\'ve got a UINavigationController with a series of UIViewControllers on it. Under some circumstances, I want to pop back exactly two levels. I thoug

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 11:42

    It works for me if you save the reference to the UINavigationViewController and use the saved instance:

    UINavigationViewController* savedUinvc = self.navigationController;
    UIViewController* one = [savedUinvc  popViewControllerAnimated:YES];
    if (...) {
        // pop twice if we were doing XYZ
        UIViewController *two = [savedUinvc  popViewControllerAnimated:YES];
        // stored in "one" and "two" for debugging, "two" is always 0 here.
    }
    

提交回复
热议问题