use*_*494 0 iphone xcode ipad ios swift
我有一个可在所有手机和平板电脑上运行的Swift iOS应用程序.我想为所有设备使用相同的代码库和IPA文件.在手机上应用程序应该是肖像.在平板电脑上应用应该是风景.
如果你的方向正确,我可以让它不允许旋转,但如果你在设备方向错误时启动应用程序,它将以错误的方向从应用程序开始,并强制你将手机实际旋转到解决它,即使这样屏幕搞砸了.
在常规:部署信息:设备方向:我已选中纵向和横向
请注意,这与已经提出的其他问题相似,但我找不到我的特殊情况.
我在所有视图控制器中使用此代码,以防止旋转,如果您已经在正确的方向:
override func shouldAutorotate() -> Bool
{
let orientation:UIDeviceOrientation = UIDevice.currentDevice().orientation
print(orientation)
if(UIDevice.currentDevice().userInterfaceIdiom == .Phone)
{
if(orientation.isLandscape)
{
return true
}
}
else
{
if(orientation.isPortrait)
{
return true
}
}
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask
{
if(UIDevice.currentDevice().userInterfaceIdiom == .Phone)
{
return UIInterfaceOrientationMask.Portrait
}
else
{
return UIInterfaceOrientationMask.Landscape
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
821 次 |
| 最近记录: |