I try to open an AlertView even I hold the tableview row 0.5 seconds.
I use for that following code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UILongPressGestureRecognizer *longTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[longTap setMinimumPressDuration:0.5];
longTap.delegate = (id)self;
[self.view addGestureRecognizer:longTap];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
[[NSUserDefaults standardUserDefaults] setObject:cellText forKey:@"CellNameToEdit"];
}
- (void)handleTapGesture:(UILongPressGestureRecognizer *)sender{
if (sender.state == UIGestureRecognizerStateBegan) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Titel" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil, nil];
alert.tag = 1;
[alert show];
}
}
This code will work, but the problem is, I have to click the row first before it opens the alert view. I hope you understand what I mean.