How can I tell when something outside my UITableViewCell has been touched?

前端 未结 3 1548
忘了有多久
忘了有多久 2021-01-01 03:44

Similar to this question I have a custom subclass of UITableViewCell that has a UITextField. Its working fine except the keyboard for doesn\'t go away when the user touches

3条回答
  •  独厮守ぢ
    2021-01-01 04:25

    I think you're on the right track, but touchesBegan:withEvent: is a UIResponder method, so you'd actually have to override it in a UIView subclass rather than in your UIViewController subclass. Your options are:

    • If you're already subclassing UITableViewCell, override touchesBegan:withEvent: there.
    • If you're using a standard UITableViewCell, implement tableView:didSelectRowAtIndexPath in your UITableView's delegate.

提交回复
热议问题