I have a tab bar application with several controllers. Some are UINavigationControllers
, some just simple UIViewControllers
.
The central button presents the UIImagePickerController
to allow the user to take a picture.
When I present the Image Picker from a simple UIViewControllers
, it works fine.
But when I present it while a UINavigationController
is currently the selectedViewController
, the dismall of the picker removes the UINavigationBar
of the controller.
I read that with UINavigationControllers
, the modal view must be presented from the navigationController
, but it does not work either.
Here are bunches of code :
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if (TARGET_IPHONE_SIMULATOR)
{
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
else
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else
{
UIAlertView* alert = [[UIAlertView alloc]
initWithTitle:@"Erreur"
message:@"Pour pouvoir poster des photos, votre device doit posséder un appareil photo"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
return;
}
}
if ([self.selectedViewController respondsToSelector:@selector(presentViewController:animated:completion:)])
{
[self.selectedViewController presentViewController:picker animated:YES completion:nil];
}
else
{
[self.selectedViewController presentModalViewController:picker animated:YES];
}
the dismall :
[self.selectedViewController dismissModalViewControllerAnimated:YES];
Has anyone got this strange behavior (guess it has something to do with the fact that UIImagePickerController
delegate must implement UINavigationControllerDelegate
) and know how to resolve that?
Thanks.