iPhone - setNeedsDisplay doesn't call drawRect

柔情痞子 提交于 2019-12-13 01:27:31

问题


I have seen many posts about this problem but didn't get an answer. I have a controller which view is added to the main window. The controller's view has a subview which has a drawRect. The problem is that this function is never called even if I call [self setNeedsDisplay].

Thanks


回答1:


It is -(void)drawRect:(CGRect)rect right? Make sure the method signature is correct, and you don't omit the rect argument even if you don't use it.

-setNeedsDisplay should be called the the subview, not self.

Also, -setNeedsDisplay won't call -drawRect: immediately. It only flushes the graphics cache so that -drawRect: is forced to be called in the next update of the frame.



来源:https://stackoverflow.com/questions/2744857/iphone-setneedsdisplay-doesnt-call-drawrect

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