0
我想打長按的tableview細胞,但我得到的錯誤:迅速GestureRecognizer
UIGestureRecognizer.Type' does not have a member named 'state'
下面的代碼
override func viewDidLoad() {
super.viewDidLoad()
var gesture: UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: "longPressed:")
gesture.minimumPressDuration = 2.0
self.view.addGestureRecognizer(gesture)
}
func longpressed() {
if(UIGestureRecognizer.state == UIGestureRecognizerState.Ended){
print("ended")
} else if (UIGestureRecognizer.state == UIGestureRecognizerState.Began){
print("began")
}
}
是的,我已經創建了橋接報頭.h並導入此文件:
#import <UIKit/UIGestureRecognizerSubclass.h>
我想要swift教程不是objective-c!
您是否嘗試將手勢添加到每個單元格對象?無需導入此類。 – Amit89
@Amit89感謝您的回覆,此代碼在Tableview中,我如何在每個單元中添加手勢? – Salah
可能重複的[UIGestureRecognizer和UITableViewCell問題](http://stackoverflow.com/questions/4604296/uigesturerecognizer-and-uitableviewcell-issue) –