如何對一個button定義兩次事件,比如,單擊時產生一個事件,然後雙擊時產生另一個不同的事件?請高手指教,謝謝!
可以用條件句 setAction :
單擊調用selectorSingleTouch.
其他調用selectorDoubleTouch.
//沒有經過編譯檢測,只是給你個思路
UITapGestureRecognizer *singleTap=[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doSingleTap)];
singleTap.numberOfTapsRequired = 1;
[self.view addGestureRecognizer:singleTap];
UITapGestureRecognizer *doubleTap=[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doDoubleTap)];
doubleTap.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:doubleTap];