在允许在编辑模式下进行选择的tableView上,当我调用tableView设置edit :NO animated:YES并退出编辑模式时,如何找到哪个是被选中的单元格?
没有调用didDeselectRowAtIndexPath:,有没有其他我忽略的方法?
为解决方案编辑:
单元格永远不会被取消选择,因此indexPathForSelectedRow仍然返回正确的值。当然可以。
发布于 2013-05-25 13:40:05
您可以使用GestureRecognizer来实现这一点。
试试这个:
UISwipeGestureRecognizer *gestureObj = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(Method:)];
[gestureObj setDirection:UISwipeGestureRecognizerDirectionRight];
[self.tableview addGestureRecognizer:gestureObj];
-(void)Method:(UISwipeGestureRecognizer *)gestureRecognizer {
CGPoint p = [gestureRecognizer locationInView:self.tableview];
NSIndexPath *indexPath = [self.tableview indexPathForRowAtPoint:p];
if (indexPath == nil)
{
[self setEditing:YES animated:YES];
NSLog(@"slide on table view but not on a row");
}
else
{
[self setEditing:YES animated:YES];
NSLog(@"slide on table view at row %d", indexPath.row);
}
UITableViewCell *cell = [self.MYArray objectAtIndex:indexPath.row];
}
发布于 2013-05-25 17:07:00
答案是该行永远不会被取消选择。
在实际退出编辑模式之前,indexPathForSelectedRow仍然有效。
https://stackoverflow.com/questions/16749931
复制