我正在使用iPhone相机拍摄图像,并调整大小并添加圆角。我有一些用户抱怨崩溃,我似乎无法找到问题。此外,选择图像后代码运行速度非常慢。
有人可以提出改进以下方法的建议吗?
-(void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[self dismissModalViewControllerAnimated:YES];
CGSize newSize = CGSizeMake(500, 500);
UIGraphicsBeginImageContext( newSize );
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *picAsPNG = UIImagePNGRepresentation(newImage);
self.imageView.image = newImage;
self.passedItem.itemImage = picAsPNG;
self.eraseButton.hidden = NO;
self.scrollImageButton.enabled = YES;
}
答案 0 :(得分:1)
这可能是内存问题吗?我知道UIImagePicker经常会在旧设备上引起内存警告:你是否在内存上发布任何警告警告你以后会在那里发出警告?