I’m creating my view hierarchy programmatically in loadView in my ViewController. I have to manually calculate the subview’s layout since autoresizing won’t work for my layout (I’ve tried a lot). I have tried putting the layout code in a helper method that gets called from the VC’s viewDidRotateFromInterfaceOrientation... and that works, but its obvious that the view rotated and then everything snapped into place. From what I’m seeing I should override the layoutSubviews method and it will animated at the same time its rotating? But since layoutSubviewsis a UIView method not a UIViewController method I would have to expose all my subviews to the view so I could identify them and set the layout. What am I missing here?
I also thought if I set the size during - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration that would work, but since the ViewController’s view doesn’t have its frame adjusted yet for the rotation it doesn’t layout properly.
I ended up making a
UIViewsubclass and laying out all subcontrol locations in this. This way I just override thelayoutSubviewsmethod and everything works. I guess this is really what Apple intended but it seems that most code I’ve seen only overridesUIViewwhen they need custom drawing, not for basic control placement.