I've got a HomeViewController
that has different modal segues to several other UIViewControllers
. If I try to show the keyboard on a UITextField
within the HomeView, everything works fine. However, if I try to show the keyboard on a UITextField
(using becomeFirstResponder
) 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:
In HomeViewController
:
- (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]
}
}
In ModalViewController
:
- (IBAction)done:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
Where done:
is linked to the "Done" button via a touch up inside event.
A few things I've tried:
dismissViewControllerAnimated:
)Anyone have an idea of what may be going on?
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;
}
@end
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 :))