Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 检测tableview上的长按_Ios_Swift_Uitableview_Uilongpressgesturerecogni - Fatal编程技术网

Ios 检测tableview上的长按

Ios 检测tableview上的长按,ios,swift,uitableview,uilongpressgesturerecogni,Ios,Swift,Uitableview,Uilongpressgesturerecogni,我知道如何简单地检测长新闻,但它会在发布后检测。如何在不松开手指的情况下检测长按 这是我现在用于长按的代码: override func viewDidLoad() { super.viewDidLoad() setupLongPressGesture() } func setupLongPressGesture() { let longPressGesture:UILongPressGestureRecognizer = UILongPressGestureRecog

我知道如何简单地检测长新闻,但它会在发布后检测。如何在不松开手指的情况下检测长按

这是我现在用于长按的代码:

override func viewDidLoad() {
    super.viewDidLoad()
    setupLongPressGesture()
}

func setupLongPressGesture() {
    let longPressGesture:UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongPress))
    longPressGesture.minimumPressDuration = 1.0 // 1 second press
    longPressGesture.delegate = self
    self.tableView.addGestureRecognizer(longPressGesture)
}

@objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer){
    if gestureRecognizer.state == .ended {
        let touchPoint = gestureRecognizer.location(in: self.tableView)
        if let indexPath = tableView.indexPathForRow(at: touchPoint) {

        }
    }
}

.end
更改为
.start

ui的文档中,长按GestureRecognitor

长时间的新闻手势是连续的。当允许的手指数(
numberoftouchsrequired
)被按下指定时间(
minimumPressDuration
)且触摸未超出允许的移动范围(
allowableMovement
)时,手势开始(
uigesturecognizer.State.begined
)。每当手指移动时,手势识别器都会转换到更改状态,当任何手指抬起时,手势识别器都会结束(
uigesturecognizer.state.end