how do I ensure a custom UIView I have is repositioned properly after an orientation change of the iPhone?
Background
- As a parent view I have a UIViewController with an XIB
- I have a custom UIView which is used in this parent (inserted in the XIB via Interface Builder). It programmatically at init creates some UIImageView’s and adds them via “self addSubview”, and then positions them via “self addSubview:imageView1” type approach
So the questions are how do I ensure I get the correct layout of these as orientation changes. Specifically:
-
Where do I trigger any such redrawing of the custom UIView? (e.g. is there a method in the parent UIViewController I should be using to trigger from?)
-
When the trigger occurs how do I request the redraw of the custom UIView? Do I need a custom method I create myself like “relayoutCustomView”? or should I be able to use an existing method in the custom UIView, in which case do I need to make sure in the custom UIView that my layout code is in a particular method?
thanks
how’s this for the answer – seems to be starting to work, not sure if it’s the best way:
How does this sound? I didn’t use the “setNeedsDisplay” anywhere…