我使用手勢識別:如何確定用戶是否在UITableViewCell上按下了2秒鐘?
初始化viewDidLoad
:
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[self.view addGestureRecognizer:longPressRecognizer];
這是longPress
樣子:
- (void)longPress:(UILongPressGestureRecognizer*)gestureRecognizer {
if (gestureRecognizer.minimumPressDuration == 2.0) {
NSLog(@"Pressed for 2 seconds!");
}
}
我怎麼能扎到這一點?
- (void)tableView:(UITableView *)tblView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
didSelectRowAtIndexPath將如何獲得對gestureRecognizer.minimumPressDuration
的引用?
基本上我想要實現的是:
**If a user clicks on a cell, check to see if the press is 2 seconds.**
你能告訴我的代碼? – 2010-07-23 00:29:33
史蒂夫似乎已經做到了。 – 2010-07-23 01:03:24