我有一个非常复杂的问题,其中按钮已经具有作为@objc函数的点击动作。我可能必须对cellForRow函数实现代码,但是仅当这些函数在起作用时,它将如何调用?
@objc func longPress(gesture: UILongPressGestureRecognizer) {
if gesture.state == UIGestureRecognizer.State.began {
print("Long Press")
//Was trying to figure out how to add segue call here
}
}
func addLongPressGesture(){
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(longPress(gesture:)))
longPress.minimumPressDuration = 0.75
self.expandButton.addGestureRecognizer(longPress)
}
您可以从表所在的ViewController向您要转到的View中的情节提要中添加序列。然后给它一个标识符并调用func performSegue(withIdentifier identifier: String, sender: Any?)
@objc func longPress(gesture: UILongPressGestureRecognizer) {
if gesture.state == UIGestureRecognizer.State.began {
print("Long Press")
performSegue(withIdentifier: String "showFromLongPress", sender: nil)
}
}
当然用您在情节提要中指定的标识符替换标识符showFromLongPress
。