Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK: How to trigger drawRect on UIView subclass after orientation change?

I am subclassing a UIView and overwrite the drawRect method. I'm noticing that the view's drawrect is only being called when the view first loads. After that it is never called again. How to I make sure it gets called after an orientation change? I've tried calling setNeedsDisplay on the view before and after the rotation and that doesn't do it.

like image 435
memmons Avatar asked Mar 26 '10 19:03

memmons


2 Answers

[myView setContentMode:UIViewContentModeRedraw];

You can set this in IB as well (i.e., set mode to "redraw")

like image 87
wcochran Avatar answered Sep 23 '22 09:09

wcochran


This was a bug related to something completely different. setNeedsDisplay does indeed cause drawRect to be called.

like image 36
memmons Avatar answered Sep 19 '22 09:09

memmons