简体   繁体   English

CADisplayLink因为remove(from:forMode :)而不是取消分配视图控制器

[英]CADisplayLink because of remove(from:forMode:) not deallocating view controller

I am facing one strange issue. 我面临一个奇怪的问题。

So I have created instance and allocated like below 所以我创建了实例并分配如下

var displayLink:CADisplayLink?

private func setupDisplayLink () {

    self.displayLink = CADisplayLink(target: self, selector: #selector(displayLinkDidFire(link:)))
    self.displayLink?.preferredFramesPerSecond = 30
    self.displayLink?.add(to: .main, forMode: .common)
}

Now to remove display link I have from this Answer 现在删除我从此答案中显示的链接

self.displayLink?.remove(from: .main, forMode: .common) // comment this line and view controller correctly deallocated 
self.displayLink?.invalidate()

because of line self.displayLink?.remove(from: .main, forMode: .common) my deinit method not called of view controller 因为行self.displayLink?.remove(from: .main, forMode: .common)我的deinit方法没有调用视图控制器

In memory graph I am not able to identify the real problem. 在内存图中,我无法识别真正的问题。 I was lucky that I have tried to comment that line and it works 我很幸运,我试图评论该线,它的工作原理

在此输入图像描述

Why that so ? 为什么这样?

Stop displayLink like this: 像这样停止displayLink:

displayLink?.invalidate()
displayLink = nil

暂无
暂无

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

相关问题 在取消分配时尝试加载视图控制器的视图 - Attempting to load the view of a view controller while it is deallocating 使用dismissModalViewControllerAnimated而不取消分配模态视图控制器 - using dismissModalViewControllerAnimated without deallocating modal view controller 尝试在取消分配<SFAuthenticationViewController>时加载视图控制器的视图 - Attempting to load the view of a view controller while it is deallocating <SFAuthenticationViewController> UISearchViewController不允许在取消分配时尝试加载视图控制器的视图 - Attempting to load the view of a view controller while it is deallocating is not allowed for UISearchViewController 更改根视图控制器不会取消分配同一窗口上的先前视图控制器 - Changing the root view controller is not deallocating the previous view controllers on the same window 试图在取消分配时加载视图控制器的视图…( <UIAlertController:> ) - Attempting to load the view of a view controller while it is deallocating… (<UIAlertController:>) 尝试在取消分配时加载视图控制器的视图。 CoreSpotlight - Attempting to load the view of a view controller while it is deallocating. CoreSpotlight 在取消分配时尝试加载视图控制器的视图... UISearchController - Attempting to load the view of a view controller while it is deallocating… UISearchController 在取消分配时尝试加载视图控制器的视图... UIAlertController - Attempting to load the view of a view controller while it is deallocating … UIAlertController 从另一个视图控制器删除视图控制器 - Remove view controller from another view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM