iPad和iPhone的不同发布方向?

时间:2012-04-13 08:08:08

标签: iphone ios ipad orientation

我正在制作一款通用应用程序,我想知道是否可以将初始方向设置为适用于iPad的Landscape和适用于iPhone的Portrait?目前,我在initial interface orientation文件中设置了info.plist,但它似乎没有针对iPad和iPhone的不同选项。如果无法通过info.plist文件完成,那么如何以编程方式完成?

3 个答案:

答案 0 :(得分:1)

以编程方式,您可以使用以下代码 -

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

        if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
            return YES;
        } 

    }
    else {

        if (interfaceOrientation == UIInterfaceOrientationPortrait) {
            return YES;
        }
    }

return NO;

}

答案 1 :(得分:1)

看起来initial interface orientation属性与supported orientation冲突。不过我找到了解决方案here

答案 2 :(得分:0)

    UIDevice* thisDevice = [UIDevice currentDevice];
    if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
    {
        [[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight];
    }
    else
    {
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
    }