1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UIScrollViewのタップの遅延をなくす

Posted at

サブクラスを作る

説明

delaysContentTouches
遅延させるか?

A Boolean value that determines whether the scroll view delays the handling of touch-down gestures

touchesShouldCancel(in view: UIView) -> Bool
ドラッグしだしたらキャンセルするか?

Returns whether to cancel touches related to the content subview and start dragging.

class NoTapDelayScrollView: UIScrollView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        delaysContentTouches = false
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        delaysContentTouches = false
    }
    
    override func touchesShouldCancel(in view: UIView) -> Bool {
        return true
    }
}
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?