http://lizhuang.iteye.com/blog/1684881
In the ipad app development How to let the device only support horizontal screen (landscape) mode, I did a number of attempts, and did not find a relatively simple setup method. I tried about 3 different ways.
1, through the Xcode set "IPad Deployment info", only select the horizontal screen left and the horizontal screen right, after the deployment test did not take effect, this method is in essence, add the following information in the Xxx_info.plist project configuration file:
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
2, this law does not take effect by setting orientation to landscape for each nib file in ib.
3, Overload shouldautorotatetointerfaceorientation: method, this way is feasible. Specific as follows:
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation
{
Return YES for supported orientations
Return ((interfaceorientation ==uideviceorientationlandscapeleft) | | (Interfaceorientation ==uideviceorientationlandscaperight));
}
If the first method is effective, then it is more perfect. Although the third way can fully meet the needs of the horizontal screen, but the implementation is more stupid, you need to overload shouldautorotatetointerfaceorientation in each controller: method, It is also possible to avoid repetitive work by extending uiviewcontroller. But it also feels a bit less straightforward, expecting someone to point out whether the SDK itself has a simple way to support it.
ipad interface layout A lot of time to do two sets of------horizontal screen and vertical screen, but in the interface switch, which layout should be judged, there are many ways, I recorded the one I used, feel more convenient:
Nsnotificationcenter *NC = [Nsnotificationcenter defaultcenter]; GET the notification centre for the app
[NC addobserver:self//add yourself as an observer
Selector: @selector (orientationchanged)
Name:uideviceorientationdidchangenotification
object:nil];//This function to get the direction of the current device,
-(void) orientationchanged
{
UIView *ftview = [Self.view viewwithtag:200];
if ([[Uidevice currentdevice] orientation] = = Uideviceorientationlandscapeleft | | [[Uidevice currentdevice] orientation] = = uideviceorientationlandscaperight)//judgment about
{
New layout of the interface
}
if ([[[Uidevice currentdevice] orientation] = = uiinterfaceorientationportrait)//I have a direction is not supported, if you want to support it then do not have the IF condition on the line
{
New layout of the interface
}
}
The real machine has been tested on IOS 5. Very convenient, use later can realize, here not more said!
Using horizontal screen for IOS