SetNeedsDisplay not working

こ雲淡風輕ζ 提交于 2019-12-03 13:04:38
Plauto Abreu

After alot of testing, I saw something related to threads and the fact setNeedsDisplay should only be called in the mainThread...besides I never started a separeted thread in this classes, the class that raised the Notification was in a secondary thread...and aparently this was causing the issue...

to Solve it I just forced setNeedsDisplay to be called in the main thread..

dispatch_async(dispatch_get_main_queue(), ^{
            [self setNeedsDisplay];  
});

Swift 3:

DispatchQueue.main.async { [weak self] in
    self?.setNeedsDisplay()
}

I think the correct way to use it is:

[self setNeedsDisplay:YES]; 

Although I always have problems to get that working :(

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!