我UI为我的iOS应用程序设计了wAny hRegular设置。
现在orientation在iPad. 但是当应用程序运行时iPhone,orientation会出现一个空白的白屏。
有什么方法可以让我只能锁定并且可以orientation使用iPhones方向iPad吗?
我UI为我的iOS应用程序设计了wAny hRegular设置。
现在orientation在iPad. 但是当应用程序运行时iPhone,orientation会出现一个空白的白屏。
有什么方法可以让我只能锁定并且可以orientation使用iPhones方向iPad吗?
您可以使用shouldAutorotate和supportedInterfaceOrientation UIViewController方法在 iPhone 上锁定旋转,但不能在 iPad 上。
只需在 中YES为 iPad 和NOiPhoneshouldAutorotate返回,然后在 中返回 iPhone/iPad 的允许方向supportedInterfaceOrientation。
是的@david"mArm"Ansermot 是对的,我刚刚添加了代码,以便快速捕捉:-
- (BOOL)shouldAutorotate {
UIDevice* thisDevice = [UIDevice currentDevice];
if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
return YES;
}
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
UIDevice* thisDevice = [UIDevice currentDevice];
if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
return (UIInterfaceOrientationMaskAll);
}
return (UIInterfaceOrientationMaskPortrait);
}
您可以从项目设置中执行此操作,请找到屏幕截图
1. http://i.imgur.com/efGrNcL.png “iPhone 设置”
2. http://i.imgur.com/I25Z2cj.png “iPad 设置”