我使用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);
}