Removing keyboard on view transition
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 w开发者_如何学Chich 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.
精彩评论