To force landscape mode, we need to set the appropriate value for the shouldAutorotateToInterfaceOrientation
method in the controller that the operation applies to:
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}
If we need to ensure that the Default.png
screen displays in landscape orientation at application startup, considering both left and right variants, we need to add a parameter to the Info.plist file:
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeLeft</string>
Additionally, to ensure proper handling of the left and right sides:
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
If it’s necessary to “rebuild” the view when the application rotates, we need to properly handle the following method:
(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[self relayoutViews];
}