在模态视图中,我有一个imageView,其中我从图库或相机设置图像。 几次它完美地工作,但随着选择的数量增加应用程序崩溃。我正在使用此代码
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *selectedImage1 = [[info objectForKey:UIImagePickerControllerOriginalImage] fixOrientation];
NSLog(@"size is %@",NSStringFromCGSize(selectedImage1.size));
CGImageRef imageRef=[selectedImage1 CGImage];
float width=CGImageGetWidth(imageRef);
float height=CGImageGetHeight(imageRef);
NSLog(@"length is %f",width*height);
if (width*height<=12012000.0) {//12MP
CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(imageRef));
float length = CFDataGetLength(data);
CFRelease(data);
NSLog(@"data==%f ",length);
if ((length/10)>10485760.0) {//10 MB
NSLog(@"data length less than 10 mb==%f ",length);
[imagePickerPopover dismissPopoverAnimated:YES];
return;
}
}else{
[imagePickerPopover dismissPopoverAnimated:YES];
return;
}
self.selectedImage=selectedImage1;
[imagePickerPopover dismissPopoverAnimated:YES];
}
我猜CFDataRef导致崩溃,可能是它没有以正确的方式发布,因为我增加了百万像素(12到16MP)应用程序的崩溃频率增加。任何想法?
答案 0 :(得分:0)
使用ELCImagePickerController,
最适合您,使用ELCImagePickerController
您可以在图库中选择多个图像,并使用滑动工具将其保存在图像视图中
您可以从Here.
获取源代码这可能对你有所帮助。
<强>感谢。强>