Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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
使UITableViewCell的某些区域不可选择_Uitableview_Swift - Fatal编程技术网

使UITableViewCell的某些区域不可选择

使UITableViewCell的某些区域不可选择,uitableview,swift,Uitableview,Swift,我有一个自定义UITableViewCell。我在单元格中有一个UIImageView,当我选择图像时,它会像应该的那样改变,但单元格也被选中,这是我不想要的。所以我的问题是,我如何才能使我的手机的某个区域不可选择? 我尝试覆盖touchesBegind或touchesEnded,但没有成功,因为我无法选择单元格。在cellForRowAtIndexPath中,可以将userInteractionEnabled设置为false: cell.userInteractionEnabled = NO;

我有一个自定义UITableViewCell。我在单元格中有一个UIImageView,当我选择图像时,它会像应该的那样改变,但单元格也被选中,这是我不想要的。所以我的问题是,我如何才能使我的手机的某个区域不可选择?
我尝试覆盖touchesBegind或touchesEnded,但没有成功,因为我无法选择单元格。

cellForRowAtIndexPath
中,可以将
userInteractionEnabled
设置为
false

cell.userInteractionEnabled = NO;

如果只想不显示选择颜色,请使用:

cell.selectionStyle = UITableViewCellSelectionStyleNone;  
如果您有由单元格点击触发的事件,它仍然会发生,因此如果您想禁用它,您也需要在以下步骤中处理:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  
或者如果它触发了一个序列,在:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender

如果我添加该行并选择图像,则单元格不会被选中,是的,但是当我想要选择单元格而不是图像时,则不会发生任何事情,因为用户交互未启用。否,我希望显示选择,并且我希望仅当用户选择单元格的某个区域时才会触发操作。如果他不接触单元格内的特定区域,则我不希望显示选择,也不希望触发操作