Reputation: 9428
I have a view controller with a input box attached to the bottom. If the input is clicked, the keyboard will show up. This view controller is pushed from a table view controller. When I click back button to the parent table view controller and come back, the keyboard will show up automatically and hover on top of the view. I tried resignFirstResponder to hide the keyboard but it didn't work.
If I click the input, the keyboard will show up like this:
Then I click the back button to its parent table view. Then I click a row in the table to enter this view again. The keyboard is still there and the input view is now under the keyboard.
EDIT1:
I tried Smiless's code. The keyboard will disappear gradually when the view appears. Is there a way to remove the slow motion disappearing?
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.view endEditing:YES];
}
Upvotes: 0
Views: 106
Reputation: 422
Try this one to dismiss the keyboard when the user taps somewhere else :
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
}
Upvotes: 2