Search code examples
iphoneobjective-cuiimagepickercontroller

UIImagePickerController reloads view after its dismissed?


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?


Solution

  • 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.