2013-06-24 51 views
0

我在我的應用程序中使用了imagepicker。它適用於大多數圖像,但是,它最初從iPhone 4相機拍攝的圖像(我認爲是因爲它們太大)而造成麻煩。來自iPhone 5相機的照片和截圖都可以正常工作。上傳最初從iPhone 4相機拍攝的照片時,選取器將它們向左旋轉90度。我認爲它也是相關的,但我的應用程序有一個功能,用戶可以將圖像保存到相機膠捲上,並且對於大多數圖像都可以正常工作,但從iPhone 4相機拍攝的旋轉90度的照片不會保存。ImagePicker將iOS相機圖像旋轉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

我不記得我使用的修復程序,但我確實記得有一個保存png表示方法丟失的問題。如果我發現我做了什麼壞事增加,但看看它。 – rezand

+0

啊,是的,保存爲PNG是問題。更改爲JPEG,它的工作! –

回答

3

這個問題仍顯示未答覆但問題/問題,通過改變PNG表示爲JPG固定。