Tôi đang sử dụng recognizers cử chỉ:Làm cách nào để xác định liệu người dùng đã nhấn vào UITableViewCell trong 2 giây?
Initialize trong viewDidLoad
:
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[self.view addGestureRecognizer:longPressRecognizer];
Đây là những gì longPress
trông giống như:
- (void)longPress:(UILongPressGestureRecognizer*)gestureRecognizer {
if (gestureRecognizer.minimumPressDuration == 2.0) {
NSLog(@"Pressed for 2 seconds!");
}
}
Làm thế nào tôi có thể buộc này vào?
- (void)tableView:(UITableView *)tblView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Làm cách nào đểSelectRowAtIndexPath tham chiếu đến gestureRecognizer.minimumPressDuration
?
Về cơ bản những gì tôi đang cố gắng để đạt được là:
**If a user clicks on a cell, check to see if the press is 2 seconds.**
bạn có thể chỉ cho tôi trong mã? –
Steve dường như đã làm điều đó. –