I'm trying to resign the keyboard when user clicks a UIButton, which triggers a new content view (of type UIViewController).
This 'compute' button is at the end of list of several textfield inputs which the user scrolls through for entry; there's no need to resign the keyboard in this view. The scrollview also accommodates resizing when the keyboard is activated.
However, I notice that when proceeding to the next view, upon button click, and then returning to this view of textfields, via the back button on the navigationbar, the keyboard remained up, and this view no longer scrolls the additional area occupied by the keyboard.
My idea is to dismiss the keyboard when the view changes, so when the view returns, any input will trigger keyboard notification and adjust the scroll view accordingly (which is working).
Thank you so much,
Something like this might get you going in the right direction:
- (void)viewWillDisappear:(BOOL)animated {
/* Dismisses the keyboard whenever the view disappears
*/
[self.view endEditing:YES];
[super viewWillDisappear:animated];
}
You could also put that endEditing call in the action handler for the "compute" button you mention.
Related
iPhone app.
I have a simple view with UITextView as first responder. I resign first responder and pop to the previous controller but the keyboard stays. Textview doesn't even exist anymore but the keyboard is still visible.
The controller that I pop to is a tableview, no objects that can even assume first responder status. So the keyboard is just there obscuring half my table and there is not even a way to dismiss it. I have to navigate back to a view that has a text box or textview, select one and dismiss that in order to get rid of the keyboard.
How is this possible?
On viewWillAppear just write
[self.view endEditing:YES];
I start by presenting a viewController modally, using the default animation where the view appears from bottom to top. In viewWillAppear, I give first responder to a text field that has a custom keyboard as its inputView. When the view animates for modal presentation, this custom keyboard appears instantly and the rest of the view animates behind it from bottom to top. When I use the default keyboard, it animates correctly with the rest of the view.
How can I get the custom keyboard view to animate while the main view is animating?
Try making your UITextField the first responder inside viewDidAppear instead of viewWillAppear.
In a Modal view controller, I'm trying to display a standard keyboard. But It's not animating. In this view, I dismiss and invoke the keyboard. But when I invoked it, there is no animation and It's just appear. (and when I dismiss the keyboard, it just slides down normally).
Any idea, why is this happening ?
I have a search display controller. If the user scrolls the table view of the search display controller after entering text into the search text field, the keyboard disappears because the search display controller is resigning first responder. Is there a way to keep the keyboard there while scrolling is occurring?
Give your UISearchBar a delegate (perhaps the same object that is the delegate of your UISearchDisplayController) and implement searchBarShouldEndEditing: to return NO in the circumstances that you do not want it to resign (for example, when mySearchDispController.searchResultsTableView.dragging is YES).
I recently discovered that if a UITextField is being edited in a controller that's attached to a UINavigationController and the back button is pressed, upon returning to this controller, the DidBeginEditing function is called again and the UITextField keyboard is brought back up. I was wondering if there's a way to stop the keyboard from coming back up. Maybe there's a way to hook the back button so it doesn't save the fact that the text field is being edited.
Implement viewWillDisappear: on the view controller that controls the text field, and call:
[theTextField resignFirstResponder];
This will dismiss the keyboard.