Ask A Question
0

UITextField fails to show keyboard after MFMailComposeViewController is dismissed

Asked by psonice on 03/24/2013 at 4:53 PM

I have an issue where the keyboard shows correctly when a UITextField is displayed, but then fails to appear after a MFMailComposeViewController is presented and dismissed. The cursor appears in the textfield, but no keyboard.

Basically, a UIView is added to the current view that contains the UITextField when the user taps a 'Create Preset' button:

[self.view addSubview:createPresetView];
[presetNameField becomeFirstResponder];

That works. The user can add multiple new presets, each time the view is added, the textfield becomes first responder, and the keyboard appears. To rule out issues with the presetNameField not being in the view hierarchy I've also tried doing becomeFirstResponder after a 1 second delay - same results.

Next, a preset can be shared via email, using a standard MFMailComposeViewController:

MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
[mailView setMailComposeDelegate:appController];
[mailView setSubject:@"New preset"];
[mailView setMessageBody:@"\n\nMail from app" isHTML:NO];
[appController presentModalViewController:mailView animated:YES];

The mail compose view dismisses correctly so far as I can tell:

[controller.view endEditing:YES]; // I added this as a test to ensure the mail view resigns first responder, no difference.
[self dismissModalViewControllerAnimated:YES];
[controller release];
controller = nil;

But now the Create Preset button adds the view with the text field, sets the textfield as first responder, but no keyboard ever appears.

I've checked out what's happening when I do becomeFirstResponder on the textfield. The textfield itself is valid, and returns YES to canBecomeFirstResponder.

The only potential clue I've found is that [presetNameField becomeFirstResponder] always returns NO (even before the mail view is shown).

Any suggestions?

View Full Answer On Stackoverflow

Responses

No responses yet. Be the first one!

    [Some content on this page is from Stackoverflow]