我正在制作一个通用应用程序,我想知道是否可以将初始方向设置为 iPad 的横向和 iPhone 的纵向?目前,我正在文件中进行设置initial interface orientation,info.plist但它似乎没有针对 iPad 和 iPhone 的不同选项。如果不能通过info.plist文件完成,那么如何以编程方式完成?
			
			1728 次
		
3 回答
            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;
}
于 2012-04-13T08:12:06.910   回答
    
    
            1        
        
		
看起来该initial interface orientation属性与supported orientations 冲突。不过,我在这里找到了解决方案。
于 2012-04-18T19:02:18.613   回答
    
    
            0        
        
		
    UIDevice* thisDevice = [UIDevice currentDevice];
    if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
    {
        [[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight];
    }
    else
    {
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
    }
于 2012-04-13T08:12:56.487   回答