Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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
Ios UIButton touchUpInside与UITableViewCell滑动事件冲突_Ios_Objective C_Uitableview_Uibutton - Fatal编程技术网

Ios UIButton touchUpInside与UITableViewCell滑动事件冲突

Ios UIButton touchUpInside与UITableViewCell滑动事件冲突,ios,objective-c,uitableview,uibutton,Ios,Objective C,Uitableview,Uibutton,我正在UITableViewCell中显示滑动按钮,如下所示: - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtI

我正在
UITableViewCell
中显示滑动按钮,如下所示:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

- (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewRowAction *cancelAction;
    UITableViewRowAction *editAction;
    UITableViewRowAction *messageAction;
     cancelAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Cancel" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
        [tableActivities setEditing:NO];
    }];
    cancelAction.backgroundColor = [UIColor blueColor];

    editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Edit" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
        [tableActivities setEditing:NO];
    }];
    editAction.backgroundColor = [UIColor greenColor];

    messageAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Message"  handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
        [tableActivities deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }];

    return @[messageAction, cancelAction, editAction];
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

}  
-(BOOL)tableView:(UITableView*)tableView canEditRowAtIndexPath:(nsindepath*)indepath
{
返回YES;
}
-(可为空的NSArray*)tableView:(UITableView*)tableView编辑操作ErrorWatIndeXPath:(NSIndexPath*)indexPath
{
UITableViewRowAction*取消操作;
UITableViewRowAction*编辑操作;
UITableViewRowAction*消息操作;
cancelAction=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@“Cancel”处理程序:^(UITableViewRowAction*action,NSIndexPath*indexPath){
[表格编辑:否];
}];
cancelAction.backgroundColor=[UIColor blueColor];
editAction=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal标题:@“编辑”处理程序:^(UITableViewRowAction*action,NSIndexPath*indexPath){
[表格编辑:否];
}];
editAction.backgroundColor=[UIColor greenColor];
messageAction=[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyle破坏性标题:@“消息”处理程序:^(UITableViewRowAction*action,NSIndexPath*indexPath){
[tableActivities deleteRowsAtIndexPaths:@[indexPath]带RowAnimation:UITableViewRowAnimationAutomatic];
}];
return@[messageAction,cancelAction,editAction];
}
-(void)tableView:(UITableView*)tableView提交的编辑样式:(UITableViewCellEditingStyle)行的编辑样式索引路径:(NSIndexPath*)索引路径{
}  
在单元格的
contentView
中,我放置了一个
ui按钮
,该按钮内部有一个
uicontrolEventTouchUp
controlEvent

当我通过触摸按钮区域来滑动单元格时,滑动和
ui按钮
事件都会触发。

如何控制此操作?

您可以通过如下方式检查
按钮中
UITableView
I编辑
属性来解决问题

- (void)btnTap:(UIButton*) sender {
    if (!self.tableActivities.isEditing) {
        //Perform Action
    }
}

欢迎快乐编码:)
UITableView.canCancelContentTouches
应该可以防止这种情况发生。@Andy:滚动条不起作用吗?