取消segue不会释放我的视图控制器 [英] Unwind segue does not release my view controllers
问题描述
我有这样的东西:
我的rootViewController
是navigationBar
-设为A.其余的都是正常的UIViewControllers
,并且通过按键(通过按钮IBAction
方法)以编程方式进行搜索.
My rootViewController
is a navigationBar
- let this be A. The rest are normal UIViewControllers
, and are programmatically segue via push (through a button IBAction
method).
但是,从D-> A出发,我使用了unsegue segue(也通过performSegueWithIdentifier:sender
:).
However going from D -> A, I use unwind segue (also via performSegueWithIdentifier:sender
:).
这里的问题是,执行segue时,B,C和D根本不是deallocated
.这不仅会导致内存泄漏问题,而且我的计时器仍在运行.我不确定为什么会这样.我以为轻松的搜寻应该为您处理所有这些吗?知道为什么吗?
The issue here is that when the segue is performed, B, C and D are not deallocated
at all. Not only is this causing a memory leak issue but my timers are still running. I'm not sure why this is the case. I thought unwind segues are suppose to handle all these for you? Any idea why?
推荐答案
问题出在NSTimer
.
NSTimer
保留其目标.因此,如果视图控制器使用target:self启动计时器,则只要计时器正在运行,它就不会被释放.
NSTimer
retain their target. So if a view controller starts a timer with target:self, it will not be deallocated as long as the timer is running.
您可以在此处 a>
这篇关于取消segue不会释放我的视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!