Have a very large program where there is always a superview that just encompasses a custom segment controller. This view sits at the top of screen and controls navigation in several ways.
So the problem arose in only a selected few view controllers where everything was 100% programmaticly created. Essentially CGRect are not being defined in the property dynamic coordinates. But are not being recalculated on orientation change. Does anyone have a simple way to control this in the subview? I’m about to code something in the superview to pass to orientation to other subviews.. but there has to be a better way. Ideas?
Couple of pointers:
You can use auto-resizing masks to determine what happens to your views when their bounds change (ie, when the orientation changes). So
UIViewAutoresizingFlexibleWidthmeans your view will ‘stretch’ proportionally with the superview when the bounds are changed.UIViewAutoresizingFlexibleLeftMarginmeans your view will effectively be right-aligned, as the left margin will adjust according to the width, etc etc.Sometimes auto-resizing masks aren’t enough – perhaps you have to change the view’s content on an orientation, or do a complex animation. In this case, you use the
willAnimateRotationToInterfaceOrientationmethod in your view controller. Your subviews might have a customadjustForOrientationmethod that you’ve written that you can trigger whenwillAnimateRotation...is called.Finally, on iOS 5 you can actually nest view controllers inside of view controllers, in which case orientation events get passed through automatically…but this is probably needlessly complex for what you’re trying to do.