【问题标题】:Is there any way to access pressesbegan method on WKInterfaceButton有什么方法可以访问 WKInterfaceButton 上的 pressesbegan 方法
【发布时间】:2019-01-13 12:29:03
【问题描述】:

我在 Xcode 中有一个 WKInterfaceButton,当我为它配置动作时,它只在点击结束时执行它,即当我的手指抬起时。

@IBAction func kickButton() {
       //Action for this button
}

我希望能够在触摸刚刚开始时执行相同的操作,例如 iOS 应用程序中的 pressesBegan 操作。我不知道有没有办法做到这一点。

【问题讨论】:

    标签: swift xcode6 watchkit watchos


    【解决方案1】:

    您可以用轻击手势识别器替换您的按钮,然后定位类似以下的功能:

    func handlePress(sender: WKTapGestureRecognizer) {
        if sender.state == .began {
            // code for when press began
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-30
      • 2018-11-30
      • 1970-01-01
      相关资源
      最近更新 更多