SetNeedsDisplay not working

前端 未结 2 1297
故里飘歌
故里飘歌 2021-02-14 13:59

I saw many threads related to this issue, but none addresses my case (I think).

My case should be simple, I have a Custom UIView in my controller, from my c

2条回答
  •  抹茶落季
    2021-02-14 14:29

    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()
    }
    

提交回复
热议问题