0
在模态的视图,我有一个ImageView的,其中i。从库或相机中设定的图像。 几次它完美,而是因为选择的数量增加应用crashes.I'm使用此代码ImagePickerController碰撞
- (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)应用程序的崩溃频率增加。任何想法?
在我的应用程序,用户添加注意到单个图像附件,我的形象在每次用户点击,他会选择相机或画廊,不管他选择我设置我的ImageView的形象,让用户可以改变这种形象多次根据他的愿望。所以当用户多次从图库中选择图像时,它会崩溃。 – kanak 2013-02-11 07:04:59