![](/img/trans.png)
[英]App support the app Landscape and portrait mode in both ipad and iphone
[英]Iphone app is working fine in both landscape and portrait mode but in ipad it only works in one mode?
我通过使用自动旋转方法制作了一个可以在iPhone上以横向或纵向两种模式正常工作的ios应用程序,我使用了以下代码
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view=Landscape;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (90));
self.view.bounds=CGRectMake(0.0,0.0,480.0,320.0);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view=Landscape;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (-90));
self.view.bounds=CGRectMake(0.0,0.0,480.0,320.0);
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
self.view=Portrait;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (0));
self.view.bounds=CGRectMake(0.0,0.0,320.0,480.0);
} else
{
self.view=Portrait;
self.view.transform=CGAffineTransformMakeRotation(deg2rad* (180));
self.view.bounds=CGRectMake(0.0,0.0,320.0,480.0);
}
}
但是对于iPad,当我旋转设备时,它只能在横向或纵向两种模式下工作,但显示空白屏幕,但如果我不旋转,则效果很好。 请引导我,因为我是iOS的新手。
需要检查的一个地方是“应用程序”目标的“常规”选项卡上的“部署信息”部分。
在“部署目标”和“设备”选择器的下方,您可以在iPhone和iPad之间切换,然后通过复选框启用受支持的方向。
如果您已经为iPad和iPhone正确设置了这些设置,那么您可能想看看如何处理UIViewControllers的supportedInterfaceOrientations
或preferredInterfaceOrientationForPresentation
方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.