Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在UITableView单元格上实现UISwipegestureRecognitor?_Iphone_Swipe_Uiswipegesturerecognizer - Fatal编程技术网

Iphone 如何在UITableView单元格上实现UISwipegestureRecognitor?

Iphone 如何在UITableView单元格上实现UISwipegestureRecognitor?,iphone,swipe,uiswipegesturerecognizer,Iphone,Swipe,Uiswipegesturerecognizer,如何在表格视图单元格中添加滑动手势?我在tableview中使用自定义单元格,我必须从表中删除该行,因此请指导我如何在tableview中使用此滑动手势?与在任何其他视图中完全相同。在自定义单元格的init或UITableViewDataSource委托的CellForRowatineXpath方法中插入此代码 UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:myTab

如何在表格视图单元格中添加滑动手势?我在tableview中使用自定义单元格,我必须从表中删除该行,因此请指导我如何在tableview中使用此滑动手势?

与在任何其他视图中完全相同。在自定义单元格的init或UITableViewDataSource委托的CellForRowatineXpath方法中插入此代码

UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:myTableViewController action:@selector(removeCell:)];
recognizer.direction = UISwipeGestureRecognizerDirectionLeft;
recognizer.numberOfTouchesRequired = 1;
[self addGestureRecognizer:recognizer];
[recognizer release];

与任何其他观点完全相同。在自定义单元格的init或UITableViewDataSource委托的CellForRowatineXpath方法中插入此代码

UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:myTableViewController action:@selector(removeCell:)];
recognizer.direction = UISwipeGestureRecognizerDirectionLeft;
recognizer.numberOfTouchesRequired = 1;
[self addGestureRecognizer:recognizer];
[recognizer release];

您必须实现两个委托方法

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
     return YES;
}
以及其他必须执行编辑或删除代码的方法

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete)  {
        //write delete code.
        [arry removeObjectAtIndex:indexPath.row];

        [Table reloadData];
    }
}

您必须实现两个委托方法

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
     return YES;
}
以及其他必须执行编辑或删除代码的方法

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete)  {
        //write delete code.
        [arry removeObjectAtIndex:indexPath.row];

        [Table reloadData];
    }
}

你帮了我。)我是个新手,所以请不要介意我那些愚蠢的问题。请给我更多的细节。cz未检测到swipetry将21更改为1。这就意味着你需要21个手指,不是吗?我是个新手,所以请不要介意我的愚蠢问题。请给我更多的细节。cz未检测到swipetry将21更改为1。这意味着你需要21个手指,不是吗?