开发者

iPhone - setNeedsDisplay doesn't call drawRect

开发者 https://www.devze.com 2022-12-28 13:43 出处:网络
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 prob开发

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 prob开发者_运维问答lem is that this function is never called even if I call [self setNeedsDisplay].

Thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消