I am using this code in the DetailView.m of a splitview app. Now the orientation changes occur only when the device is rotated. The detection does not take place when the app is launched. I also get this warning
warning: ‘RootViewController’ may not respond to ‘-adjustViewsForOrientation:’
What change do I need to make the app adjust the orientation code when the app is launched.
> - (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
> duration:(NSTimeInterval)duration {
> [self adjustViewsForOrientation:toInterfaceOrientation];
> }
>
> - (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation
> {
> if (orientation == UIInterfaceOrientationLandscapeLeft ||
> orientation ==
> UIInterfaceOrientationLandscapeRight)
> {
> detailDescriptionLabel.center = CGPointMake(235.0f, 42.0f);
> bigthumbImageView.center = CGPointMake(355.0f, 70.0f);
>
> }
> else if (orientation == UIInterfaceOrientationPortrait ||
> orientation ==
> UIInterfaceOrientationPortraitUpsideDown)
> {
> detailDescriptionLabel.center = CGPointMake(160.0f, 52.0f);
> bigthumbImageView.center = CGPointMake(275.0f, 80.0f);
>
> } }
To remove the warning, move the definition of
-adjustViewsForOrientation:before-willRotateToInterfaceOrientation:….The
-willRotateToInterfaceOrientation:…method will only be called when there’s an interface rotation. When the app was first launched, the interface doesn’t rotate (it follows the initial orientation), so this call is not generated. You have to call it manually, e.g. in-viewDidLoad: