我有将大小约为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];
}
可以在不压缩原始图像的情况下进行此操作吗?
答案 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这个代码,这会使图像尺寸变小。