微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

是否可以将UITapGestureRecognizer与pickerView didSelectRow结合使用?

如何解决是否可以将UITapGestureRecognizer与pickerView didSelectRow结合使用?

我决定在我的pickerview中添加一个轻击手势,是否可以将UITapGestureRecognizer与UiPickerView didSelectRow结合使用?

''' @objc func tappedToSelectRow(tapRecognizer:UITapGestureRecognizer){

    if tapRecognizer.state == .ended {
    let rowHeight = mainPicker.rowSize(forComponent: 0).height
    let selectedRowFrame = mainPicker.bounds.insetBy(dx: 0,dy: (mainPicker.frame.height - rowHeight) / 2.0)
    let userTappedOnSelectedRow = (selectedRowFrame.contains(tapRecognizer.location(in: mainPicker)))
        if userTappedOnSelectedRow {
            func pickerView(_ pickerView: UIPickerView,didSelectRow row: Int,inComponent component: Int) {

            self.clearResults()

            if pickerView.tag == 0 {
                currentTypeSelection = row
                self.selectedSettingType = self.viewmodel.settingtype[row]
                rslt1.text = self.viewmodel.settingtype[row]
                rslt1.resignFirstResponder()
                currentSizeSelection = 0
                mainPicker.isHidden = true
                rslt2.text = ""
                rslt3.text = ""
                SettingType.layer.removeAllAnimations()
                Stoneshape.isEnabled = true
                Clear.isEnabled = true
                Clear.alpha = 1
                if rslt2.text == ""{
                    self.focusButton(button: self.Stoneshape)
                } else {
                    focusButton2()
                }
                
                if rslt1.text == "Hand U-Pave"{
                    self.rslt2.text = "Round"
                    self.focusButton(button: self.Stonesize)
                    }
                }
            }
        }
    }
}

'''

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。