Dismissing UIImagePickerController from UITabBarController
- by Dave
I have a tab bar application whereby one tab uses a navigation controller to move through a series of views. On the final view, there is a button to add a photo, which presents a UIImagePickerController. So far, so good - however when I finish picking the image, or cancel the operation, the previous view is loaded, but without the tab bar. I'm sure I'm missing something elementary, but any suggestions on how to properly release the UIImagePickerController would be much appreciated. The code is as follows:
ImagePickerViewController *aController = [[ImagePickerViewController alloc]; initWithNibName:@"ImagePickerViewController" bundle:[NSBundle mainBundle]];
[self presentModalViewController:aController animated:YES];
[aController release];
//viewDidLoad
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
if([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]){
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
} else {
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[window addSubview:imagePickerController.view];
//ImagePickerViewController imagePickerControllerDidCancel - FinalViewController is the last view in the stack controlled by a navigation controller which contains the button to present the UIImagePickerController
[picker dismissModalViewControllerAnimated:YES];
FinalViewController *aController = [[FinalViewController alloc initWithNibName:@"FinalViewController" bundle:[NSBundle mainBundle]];
[picker presentModalViewController:aController animated:YES];
[aController release];