Maybe a basic problem, it’s my first app dealing with different orientations on iPad.
UIView1
–> UIButton
–> Presents UIView2
In UIView1 and UIView2 i set the frame and Size of containing Views depending on orientation in
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
This is ok. But if View2 is in focus, the orientation changes and i close View2, View1 did not respond to orientation change. The View itself is in correct orientation, but the calculation of frame and size of in UIView1 contained elements is not executed.
What is the “correct” way to do this? Do i have to call a delegate method in View2 to set the new positions in View1 (hopefully resisting in background if it was not released because of memory)?
MadMaxApp
You could implement
or
in your view controllers.
Those methods will be called before the rotation changes and gives you a possibility of manually handling the rotation. This can be useful if the autoresize is not giving the correct results (I understand you are doing some custom calculations about your views layout in
shouldAutorotateToInterfaceOrientation, so it might be the case).On a more general note, consider that there are several methods that deal with rotation; they have different responsibilities:
shouldAutorotateToInterfaceOrientation: it just says which orientation are supported;willAnimateRotationToInterfaceOrientation:duration: this is the place where you can modify frames, sizes, positions, etc. when you want that those changes take effect during while the rotation is occurring;willRotateToInterfaceOrientation:duration:: do here whatever is necessary: stopping animations, timers, live update and so on;didRotateFromInterfaceOrientation:: do here the opposite to 3.This is just a guideline, of course. You could