LoginSignup
7
3

More than 5 years have passed since last update.

UITableViewのセルが無い部分は後ろにあるビューにタップを流す

Last updated at Posted at 2016-11-16
final class ThroughTableView: UITableView {
  override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
    if let _ = indexPathForRow(at: point) {
      return super.hitTest(point, with: event)
    } else {
      return nil
    }
  }
}

hitTestでセルがあるか見てあげてあれば普通にhitTest/無ければそのままタップイベントを流す。

ここでselfを返したりするとセルのタップの反応が悪くなったりするので注意

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3