sapanda sapanda - 1 year ago 63
iOS Question

iOS 7: Keyboard not showing after leaving modal ViewController

I've got a

that has different modal segues to several other
. If I try to show the keyboard on a
within the HomeView, everything works fine. However, if I try to show the keyboard on a
) after returning from any of the modal View Controllers, the keyboard never shows.

Here's some sample code from one of the setups I've tried:


- (void)viewDidAppear:(BOOL)animated
static BOOL firstTimeComplete = false;
if (!firstTimeComplete) {
firstTimeComplete = true;
} else {
UITextField *textField = [[UITextField alloc] init];
[self.view addSubview:textField];
[textField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:3]


- (IBAction)done:(id)sender
[self dismissViewControllerAnimated:YES completion:nil];

is linked to the "Done" button via a touch up inside event.

A few things I've tried:

  • Converting the modal segues to push segues fixes the issue, but I don't want a Nav bar in any of the child views

  • I've tried disabling and enabling animations when dismissing the
    modal view controller (using

  • Using unwind segues in the storyboard rather than doing it programmatically

Anyone have an idea of what may be going on?

Answer Source

After deleting tons of code, I finally found out that a custom NavigationController was being used and this was the root cause:

@implementation MSLNavigationController

- (NSUInteger)supportedInterfaceOrientations
    return UIInterfaceOrientationPortrait;

- (BOOL)shouldAutorotate
    return NO;


The app doesn't need this code, so I've nuked the file. (But an explanation as to why this would be hiding the keyboard would be awesome :))

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download