简体   繁体   English

展开到不在当前导航视图控制器链中的viewController

[英]Unwind to a viewController that is not in the current navigation view controller chain

I have the following scenes in the storyboard 我在storyboard有以下场景

VC1 => NavC => VC2 => VC3 => VC4 I programmatically segue from VC1 to either VC2 or VC3 based on a condition (I am doing that by instantiating NavC and change the viewControllers array). VC1 => NAVC => VC2 => VC3 => VC4予编程segue从VC1基于任一VC2或VC3上的条件(我这样做,通过实例NAVC和改变viewControllers数组)。 Now I would like to unwind from VC4 to VC1, but I think I am doing something wrong, because it is ignored and nothing is happening. 现在,我想从VC4放松到VC1,但是我认为我做错了什么,因为它被忽略了并且什么也没有发生。 To do this I have defined an IBAction called unwind1 in VC1, then I have created an exit segue from VC4 to its exit and called it segue1. 为此,我在VC1中定义了一个名为unwind1的IBAction ,然后创建了一个从VC4到其出口的出口segue ,并将其称为segue1。 I also have subclassed UINavigationController and have the following methods in it: 我还UINavigationController并在其中包含以下方法:

override func viewControllerForUnwindSegueAction(action: Selector, fromViewController: UIViewController, withSender sender: AnyObject!) -> UIViewController {
    return self.presentingViewController!
}

override func segueForUnwindingToViewController(toViewController: UIViewController, fromViewController: UIViewController, identifier: String?) -> UIStoryboardSegue {
    return UIStoryboardSegue(identifier: identifier, source: fromViewController, destination: toViewController)
}

In method1 of VC4 I make a call to self.performSegueWithId("unwind1") . 在VC4的method1中,我调用了self.performSegueWithId("unwind1") Although when I trace the execution control reaches to this line but it is ignored. 尽管当我跟踪执行控制到达此行时,它却被忽略了。 When I put breakpoint in the two above-mentioned methods, execution control never gets there. 当我在上述两种方法中设置断点时,执行控制就永远不会实现。 Any thoughts on what I am doing wrong? 对我在做什么错有任何想法吗?

It seems that what I have done is the correct solution to the problem, because I just noticed it works on ios 8.1, but it does not work on ios 8.0. 看来我所做的是对问题的正确解决方案,因为我刚刚注意到它在ios 8.1上有效,但在ios 8.0上却无效。 I assume it is a bug in the iOS! 我认为这是iOS中的错误!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何展开导航堆栈上的第一个视图控制器 - How to unwind to the first view controller on a navigation stack 以编程方式推送至导航堆栈中的视图控制器[2],然后展开至[1] - Programmatically push to view controller [2] in a navigation stack, and unwind to [1] 从导航控制器到视图控制器的Swift自定义展开Segue - Swift custom unwind Segue from Navigation controller to View Controller 导航控制器的视图作为ViewController中的子视图 - Navigation Controller's view as a subview in a ViewController 如果显示并推送了当前视图控制器,如何退回到右视图控制器? - How to unwind to the right view controller if current one is presented AND pushed? 在 unwind segue、dismiss 和 popViewController 之间选择以“关闭”当前视图 controller - Choose between unwind segue, dismiss and popViewController to “close” current view controller 从当前的视图控制器中打开一个新的ViewController - Open a new ViewController from a current view controller 展开控制器中的导航控制器清除 - Navigation Controller Clear in Unwind Segue 以编程方式将视图控制器添加到导航控制器,然后推送另一个视图控制器 - Add viewcontroller to navigation controller programmatically then push another view controller 如何找到属于当前viewController的导航控制器? - How do I find out the navigation controller that is part of the current viewController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM