UIImagePickerController reloads view after its dismissed?

时光毁灭记忆、已成空白 提交于 2019-12-04 05:21:28

问题


I create the picker:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];

and I handle the didFinishPickingMediaWithInfo:

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
[picker release];}

but this calls the viewDidLoad on self. This is not normal is it? Whats wrong?


回答1:


Your app probably received a memory warning, which caused all view controllers who are not displayed on screen to unload their views. This is quite normal while you are in the image picker because the camera needs a lot of memory. The moment you dismiss the image picker your view controller reloads its view.

As this is perfectly normal behavior, your app must deal with this situation correctly.




回答2:


I had a similar issue with this, I was displaying a popup during a long press gesture. It appeared as though the modal was not dismissed after the image was selected. However, the long press gesture event gets called several times, so a new popup was being displayed for every event. In my gesture handler I do something like this as to fix:

if (![imagePickerPopoverController isPopoverVisible]){
   //show pop-up etc
}



回答3:


I had some kind of that issue and I'd tried to set presentation "Over full screen" and it worked without reloading



来源:https://stackoverflow.com/questions/2682844/uiimagepickercontroller-reloads-view-after-its-dismissed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!