3
我正在編寫一個僅限LandScape的iPad應用程序,我需要從庫中發送圖片以發送數據庫,但圖像上傳屏幕只能在縱向模式下使用。我如何將其更改爲橫向模式?我讀過一些關於UIPickerControllerDelegate的內容,它不支持橫向模式,但是一些應用程序(如iMessage)已經在使用它。在Swift 2.0中以橫向模式使用UIImagePickerController
這裏是我的代碼:
class signUpViewController: UIViewController,UIPickerViewDataSource, UIPickerViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
print("Image Selected")
self.dismissViewControllerAnimated(true, completion: nil)
profileImageView.image = image
}
@IBAction func importImage(sender: AnyObject) {
var image = UIImagePickerController()
image.delegate = self
image.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
image.allowsEditing = false
self.presentViewController(image, animated: true, completion: nil)
}
}
爲了解決這個問題,我必須啓用肖像模式,但我的應用程序不支持它,因此我無法啓用它。如果縱向模式已啓用,代碼將在橫向模式下工作,但當我禁用縱向模式時,它不起作用。 –
我已添加覆蓋func shouldAutorotate() - >布爾{ 返回false }這對每個視圖控制器來說,它的壞但有用的解決方案。你有其他想法嗎?感謝您的幫助 –
它的工作Charmly – Ben10