我在我的应用中使用了一个imagepicker。它适用于MOST图像,然而,它最初从iPhone 4相机拍摄的图像有问题(我想因为它们太大了)。来自iPhone 5相机的图片和截图都可以正常工作。上传最初从iPhone 4相机拍摄的照片时,拾取器将它们向左旋转90度。我认为这也是相关的,但我的应用程序有一个功能,用户可以将图像保存到他们的相机胶卷,它适用于大多数图像,但从iPhone 4相机旋转90度拍摄的图像不保存。
这是我的代码:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if ([self.imagePicker isEqual:picker])
{
//
// Saving into Documents folder
//
NSString* path = [NSHomeDirectory() stringByAppendingString:@"/Documents/one.png"];
BOOL ok = [[NSFileManager defaultManager] createFileAtPath:path
contents:nil attributes:nil];
if (!ok) {
NSLog(@"Error creating file %@", path);
} else {
NSFileHandle* myFileHandle = [NSFileHandle fileHandleForWritingAtPath:path];
[myFileHandle writeData:UIImagePNGRepresentation(info [UIImagePickerControllerOriginalImage])];
[myFileHandle closeFile];
}
//
// Loading from documents
//
NSFileHandle* myFileHandle = [NSFileHandle fileHandleForReadingAtPath:path];
UIImage* loadedImage = [UIImage imageWithData:[myFileHandle readDataToEndOfFile]];
self.chosenImageOne = loadedImage;
[self.imageViewOne setImage:self.chosenImageOne];
[self dismissViewControllerAnimated:YES completion:nil];
}
}
答案 0 :(得分:3)
这个问题仍然没有得到解决,但问题/问题是通过将png表示更改为jpg来解决的。