开发者

iPhone Crashes After UIImagePickerController Finishes

I am using the iPhone camera to capture an image and them resizing and adding a rounded corner. I'm having so开发者_开发知识库me users complain about crashes and I can't seem to find the problem. Also, the code runs very slow after selecting an image.

Can anyone offer suggestions to improve the method below?

-(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;
}


Could it be a memory problem? I kwow UIImagePicker often causes memory warnings on older devices: are you releasing anything upon memory warning that you're assuming will be there later?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜