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

memmons picture memmons · Mar 26, 2010 · Viewed 9.6k times · Source

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.

Answer

wcochran picture wcochran · Jan 26, 2012
[myView setContentMode:UIViewContentModeRedraw];

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