我使用UIImagePickerController捕捉圖像使用相機。我的應用支持的方向是肖像。我看到iPhone 5的奇怪行爲。我正在使用Xcode 7和Swift 2.0。 iPhone 5操作系統版本是8.4。我的應用的部署目標爲8.0。從UIImagePickerController獲取圖像後,UIImageView旋轉圖像iPhone 5
問題是。 1.對於iPhone 5,拍攝圖像後,圖像以拍攝圖像的相應模式顯示。但是在按下'使用照片'標準選項後,當圖像顯示在UIImageView上時,圖像會自動旋轉到左側。不知道爲什麼。如果我從照片庫中選擇圖像,圖像不會旋轉。我不想讓圖像旋轉。 我看到類似的帖子,更好的解釋和實際的形象,但沒有回答。 UIImageView rotates image with retina 4 iPhone simulator but not retina 3.5/regular simulator 我嘗試了幾乎所有這個帖子的快速解決方案:iOS UIImagePickerController result image orientation after upload和其他帖子,但似乎沒有任何工作。我使用了shouldAutorotate(),sFunc_imageFixOrientation(),並添加了這篇文章的擴展。
- 此外,對於這兩種設備,按'使用照片'選項後,上傳圖像大約需要10秒。它可以做得更快。
這裏是我的代碼:
FUNC openCamera(){
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
dispatch_async(dispatch_get_main_queue(), {
let imagePicker = UIImagePickerController();
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera;
imagePicker.allowsEditing = false;
imagePicker.delegate = self;
imagePicker.modalPresentationStyle = .FormSheet
self.presentViewController(imagePicker, animated: true, completion: nil);
});
}
}
func openGallary() {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary;
imagePicker.allowsEditing = true
self.presentViewController(imagePicker, animated: true, completion: nil)
}
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
profileImage?.image = image
self.dismissViewControllerAnimated(true, completion: nil);
}