Remove UIViewController from memory after Modal Segue

时间:2015-12-14 18:10:58

标签: ios memory uiviewcontroller presentmodalviewcontroller

I'm On UIViewController 'A'. I'm presenting(Modally - Cross Dissolve) UIViewController 'B'.

After 'B' is presented, When i touch/tap the View, TouchesBegan of 'A' is triggered. So i figured i need to remove 'A' from memory after 'B' is presented.

I tried :

 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "gameLevel"
        {
            if let viewController: ViewController = segue.destinationViewController as? ViewController {

                self.dismissViewControllerAnimated(false, completion: nil)
            }
        }
    }

Dosent seem's to work. Any suggestion how to remove 'A' from memory after i moved to 'B'?

1 个答案:

答案 0 :(得分:2)

我不明白为什么你应该这样做。如果您要呈现视图控制器,您的用户体验设计应该让用户返回它。这是预期的设计;如果你不想要这种体验,请不要使用presentViewController:animated

此外,SDK中也没有黑客可以做到这一点。如果您查看文档,这将非常明显,presentingViewController是一个强大的参考。

您可能需要删除所有视图层次结构并设置应用委托的rootViewController属性。你可能没有得到动画;但底层视图控制器可能被取消分配。