Question

Any uitextfield I add to a view which is presented from another view controller with presentModalViewController:animated: does not respond to any touch events (like the keyboard doesnt display when the uitextfield is tapped) also if i use [textField becomeFirstResponder] to force the keyboard to display, the only time this works is in the viewDidLoad method of the view controller

Anyone know why the uitextfield is not responsive whatsoever when i use presentModalViewController:animated: to display the view controller which the uitextfield is on?

Was it helpful?

Solution 2

after much trouble i came to find that

-(BOOL)canBecomeFirstResponder {    
    return YES; 
}

was hidden in my code somewhere, this for some reason was not allow the textfield to become first responder if i added the view via the presentModalViewController:animated: method

OTHER TIPS

This Q&A is old, but I have just noticed the same behaviour with a UIWebView (with input fields) presented modally and found a workaround to preserve

- (BOOL)canBecomeFirstResponder {    
    return YES; 
}

If this method is removed or return NO, the keyboard shows up correctly (as pointed out by DotSlashSlash), but the same result is obtained putting

[self resignFirstResponder];

just before

[self presentModalViewController:aViewController animated:animated];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top