2011-03-20 39 views
2

我想知道如何去檢測我在UIButton上的長按嗎?我聽說過UILongPressGestureRecognizer,但完全不確定如何使用它。我如何檢測長按?

回答

3

我不知道有關UILongPressGestureRecognizer,但是當按鈕被擊中時,計時器熄滅檢查,看它是否仍然下跌,你可以啓動一個NSTimer,然後。

7

使用此:

UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(selectorname)]; 
[anyView addGestureRecognizer:longPressGesture]; 
[longPressGesture release]; 
+1

這並不提供對一個UIButton適當的期望行爲 – 2011-06-22 13:57:19