Memory warning after using the UIImagePicker once

后端 未结 3 1943
囚心锁ツ
囚心锁ツ 2021-02-05 13:59

I\'ve referred to this very good reference: https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more but I\'m having some very serious issues.

3条回答
  •  走了就别回头了
    2021-02-05 14:40

    For all the people that are still looking for the actual answer and not a vague statement then look here. I noticed there are hundreds of answers such as "Handle your memory" but that doesn't answer anything. Hope this helps someone else out there...

    Change the following

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
        [imageView setImage:image];
        [self dismissModalViewControllerAnimated:YES];
    }
    

    To the following so your modal view dismisses before setting your image...

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
        [self dismissModalViewControllerAnimated:YES];
        [imageView setImage:image];
    }
    

提交回复
热议问题