简体   繁体   English

IOS Universal App Rotation

[英]IOS Universal App Rotation

I have recently converted my IPad application into a Universal Application. 我最近将我的IPad应用程序转换为通用应用程序。 I am re-using a lot of views from my IPad version to the IPhone version. 我正在重复使用从我的IPad版本到IPhone版本的大量视图。

The IPad needs to support all orientations, is there a way to specify the IPad version to allow any orientation, but IPhone to just allow portrait? IPad需要支持所有方向,有没有办法指定IPad版本允许任何方向,但IPhone只允许纵向?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && interfaceOrientation != UIInterfaceOrientationPortrait)
    {
        return NO;
    }
    else
    {
        return YES;
    }
}

As you might guess, there are some alternative ways to get the same result. 正如您可能猜到的,有一些替代方法可以获得相同的结果。 The following would let you define multiple orientations for each device. 以下内容可让您为每个设备定义多个方向。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    else
    {
        return YES;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM