0
我试图强制一个视图在我的ipad应用程序的方向,但我无法保持它的持久性。强制一个视图的ipad方向
例如,我在我的收藏视图中显示肖像,我选择了一个图像(这是风景)。我检查它的宽度,并在我的viewPhoto的viewWillAppear中设置高度,以便将设备设置为横向。 “设备”旋转,以及。当我在人像后手动旋转它时,我希望它保持在横向,但不是。
这里是我的代码:
override func viewWillAppear(animated: Bool) {
// Remove hairline on toolbar
mytoolBar.clipsToBounds = true
// Load image from svg
let img = getImageFromBase64(arrayBase64Images[index])
imgView.image = img
var value: Int
if (img.size.width > img.size.height) { // turn device to landscape
value = UIInterfaceOrientation.LandscapeRight.rawValue
}
else { // turn device to portrait
value = UIInterfaceOrientation.Portrait.rawValue
}
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
检查这一点,http://stackoverflow.com/questions/ 12640870/IOS -6-力设备取向 - 横向 – Vijay