Question

Possible Duplicate:
Dismiss keyboard by touching background of UITableView

I have a custom UIScrollView which contains UITableView and UITextView. When user clicks on text field, keyboard pops up and it also disappears when user presses Return key on keyboard.

Question: How to get rid of keyboard when user taps on UITableView? No matter what I try, I just can't catch any touch events... Using iPhone 3.0 SDK since that does seem to make a big difference. As far as I understand touch events are not automatically redirected to... anywhere! Still there are touch events, since I can scroll table view up/down, even I don't want to!

What do I have to do to dismiss keyboard, when user presses somewhere else but keyboard itself or the text field?

Was it helpful?

Solution

- (void) tableView:(UITableView *)_tableView didSelectRowAtIndexPath:(NSIndexPath *)_indexPath {
    if ([self.textView isFirstResponder])
        [self.textView resignFirstResponder];
    //...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top