UINavigationBar is being moved after UIImagePickerControllerDidCancel?

I have a problem where I fashionably present a UIImagePickerController from a UINavigationController and the user clicks cancel instead of taking a photo. I dismiss the view from the UIImagePickerControllerDidCancel callback, however when I go back to the previous view, the entire view (including the navigation bar) moves a few pixels. Another thing that is extremely strange is that when I select a text field in this view, the keyboard is displayed partially off-screen. This only happens on my iPhone (I imagine it in a popover controller for iPad and it has no problem).

Here is my code for the didCancel callback:

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
    {
        [popoverController dismissPopoverAnimated:YES];  
    }
    else//for iPhone
    {   
        [picker dismissViewControllerAnimated:YES completion:nil];    
    }
}

      

Any ideas?

+3


source to share


1 answer


Use this line:

[self dismissViewControllerAnimated:YES completion:nil];

      



Instead of this line:

[picker dismissViewControllerAnimated:YES completion:nil]; 

      

0


source







All Articles