Delay of button's highlighted state

前端 未结 3 951
一整个雨季
一整个雨季 2021-02-05 18:11

I have the issue in two completely different situations, which makes it really weird.

  1. Situation: A UIButton in as a subView of another UIView.
  2. Situation:
相关标签:
3条回答
  • 2021-02-05 18:18

    Are the UIButtons inside a UIScrollView ? If they are, the delay is there so the scrollview can determine whether the touch is for scrolling or it should be passed on to the subview.

    See also UIButton touch is delayed when in UIScrollView

    0 讨论(0)
  • 2021-02-05 18:29

    This can happen if the buttons are placed close to the bottom edge of the display. There's a conflict with the system edge gesture to present Control Center (or App Switcher on iPhone X and iPad). It delays touches for your buttons until it's determined the user isn't performing a system gesture.

    If you would like, you can tell the system to give precedence to your gestures over the system gestures.

    override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
        return .bottom
    }
    

    Do note however that this will require the user swipe twice to activate the system gesture.

    0 讨论(0)
  • 2021-02-05 18:41

    I know it's been a long time, but I just faced a similar issue:

    • My UIButton is a subview of UINavigationController.view
    • There's no delay on the simulator
    • But there's a delay to show the highlight on the device

    I just found out that it only happens if I run the app from Xcode. If I disconnect the device and open the app from it's icon everything works just fine.

    I hope it helps.

    0 讨论(0)
提交回复
热议问题