防止解雇UIViewController与presentViewController

时间:2016-05-23 17:31:56

标签: ios swift uiviewcontroller presentviewcontroller

我的应用中有两个UIViewControllers。在UIViewControllerA上执行操作加载UIViewControllerB或UIViewControllerC没有问题。

let destinationViewController = self.storyboard?.instantiateViewControllerWithIdentifier("UIVCB") as! ViewControllerB
destinationViewController.results = result
self.presentViewController(destinationViewController, animated: true, completion: nil )

(我想以模态方式呈现第二个视图控制器(B或C) ,因为我希望用户在那里处理某些内容而返回到UIViewControllerA,直到他或她已经这样做了。)

问题是在UIViewControllerB或UIViewControllerC上单击任何地方会将用户返回到UIViewControllerA。起初我以为我是在错误地实例化这些,但有人在这里回答并指出这不是问题。 (而且我发现很难相信问题在于B或C中的代码,因为它影响了它们。)

我找到了数十(数百?)个搜索结果,详细说明了如何解雇一个呈现的viewcontroller,但我似乎找不到任何解释如何阻止解雇一个。

使用presentViewController()以这种方式加载第二个视图我错了吗?或者我只是遗漏了一些显而易见的东西,以防止第二个控制器因点击屏幕上的任何位置而被解雇?

更新:如果我使用此代码来实例化B或C,则问题是“点击任意位置以解除问题"消失了:

self.navigationController?.pushViewController( destinationViewController, animated: true )

但我假设我不应该调用navigationController和/或推送和弹出,因为B和C应该是模态的并且在导航堆栈之外。

0 个答案:

没有答案