gpt4 book ai didi

ios - 在相机 UIImagePickerController 中收到内存警告

转载 作者:可可西里 更新时间:2023-11-01 06:17:33 25 4
gpt4 key购买 nike

当我进入相机 UIImagePickerController 时,我有时会收到一条内存警告消息,我不知道如何解决这个问题。

这是我的代码:

    -(IBAction)addImageCamera:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
pickerImgCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraView.image=[img imageFromMainBundleFile:@"frameCam.png"];
pickerImgCamera.cameraOverlayView=cameraView;

[self.navigationController presentModalViewController:pickerImgCamera animated:NO];

}
else
{
UIAlertView*alert=[[UIAlertView alloc] initWithTitle:@"Oops" message:@"Camera not found" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
alert=nil;
}
}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
{
[self dismissModalViewControllerAnimated:YES];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

});
}

[photoImage setImage:image];
}

注意:内存警告出现在iphone和ipad上。

最佳答案

根据我的经验,iPhone 相机会频繁触发内存警告,尤其是在旧设备上。当您调试时更有可能发生 - 诀窍是处理警告并摆脱不必要的东西。

关于ios - 在相机 UIImagePickerController 中收到内存警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12833573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com