开发者

How to get rid of keyboard when user taps background (iPhone) [duplicate]

This question already has answers here: Closed 10 years ago.

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?


- (void) tableView:(UITableView *)_tableView didSelectRowAtIndexPath:(NSIndexPath *)_indexPath {
    if ([self.textView isFirstResponder])
        [self.textView resignFirstResponder];
    //...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜