IM在輕敲姿勢實驗依奧斯TapGestures
我試圖點擊手勢添加到視圖,但是當發生點擊我得到一個錯誤
這裏是我的代碼:
class ViewController: UIViewController {
@IBOutlet weak var myView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
myView.backgroundColor = UIColor.redColor()
let tapGestureRecognizer:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "TapPageHandler")
myView.addGestureRecognizer(tapGestureRecognizer)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func TapPageHandler(recognizer: UITapGestureRecognizer){
print("hello world")
}
}
和我得到的錯誤是:
2016年5月14日20:08:47.753 TapGestureTest [6641:245475] - [TapGestureTest.ViewController TapPageHandler]:無法識別的選擇發送到實例0x7fc1fb58f430 2016年5月14日20:08:47.813 TapGestureTest [6641:245475 ***終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是:「 - [TapGestureTest.ViewController TapPageHandler]:
任何人都可以指導我這個?並說出爲什麼發生這種情況