无法将VERY BIG(HEAVY)UIImage传递给另一个UIViewController

时间:2014-11-18 09:30:36

标签: ios objective-c uiimageview uiimage uiimagepickercontroller

我有将大小约为300 MB的图片传递给另一个UIViewController的问题。我可以传递任何其他图像,但它们的大小不是那么大。

首先,在第二个UIImagePickerController中选择我显示预览窗口的图像后,我在第一个UIViewController中调用UIViewController。试图使用UIImagePickerControllerReferenceURL密钥,但也无效。

我的代码如下:

1)第二个UIViewController传递图像

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController
@property (nonatomic, strong) UIImage *selectedImage;
@end

2)在我的第一个UIViewController

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage];

    SecondViewController *vc = [SecondViewController new];
    vc.selectedImage = selectedImage;

    [imagePickerController pushViewController:vc animated:YES];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(finishedToPickImage) name:@"finishedToPickImage" object:nil];
}

可以在不压缩原始图像的情况下进行此操作吗?

1 个答案:

答案 0 :(得分:0)

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    selectedImage = [info objectForKey:UIImagePickerControllerEditedImage];

    SecondViewController *vc = [SecondViewController new];
    vc.selectedImage = selectedImage;

    [imagePickerController pushViewController:vc animated:YES];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(finishedToPickImage) name:@"finishedToPickImage" object:nil];
}

尝试使用UIImagePickerControllerEditedImage这个代码,这会使图像尺寸变小。