如何禁用UITableview单元格的UserInteraction,但不能在单元格的自定义按钮中禁用 [英] how to disable UserInteraction for UITableview cell but not in custom button on cell
问题描述
如何禁用UITableview
单元格的UserInteraction
,但不能在该单元格的自定义按钮中禁用..
How to disable UserInteraction
for UITableview
cell but not in custom button on that cell..
我正在使用以下按钮创建一个按钮:
I am creating a button using :
UIButton *dayButton = [UIButton buttonWithType:UIButtonTypeCustom];
[dayButton setFrame:CGRectMake(201, 0, 30, 35)];
[dayButton addTarget:self action:@selector(selectDayView) forControlEvents:UIControlEventTouchUpInside];
[dayButton setBackgroundImage:[UIImage imageNamed:@"86-camera.png"] forState:UIControlStateNormal];
dayButton.userInteractionEnabled=YES;
[cell addSubview:dayButton];
然后我设置
cell.userInteractionEnabled=NO;
我如何获得dayButtonAction
?
推荐答案
不能为UITableView而不是在UITableViewCell
上应用禁用userInteraction
.当启用userInteraction
的userInteraction
时,您可以访问UITableVie的内容/控制器(这是UITableView
的子视图).当您在UITableView
上添加任何控制器时,实际上是在UITableViewCell
上添加了它,但是单元格是UITableView
的一部分,因此,当在UITableView
上禁用userInteraction
时,这意味着它也将UITableViewCell设置为(NO).
It is not possible to applies disable userInteraction
for UITableView and not on UITableViewCell
. You can access content/controllers of UITableVie (which is sub View of UITableView
) when userInteraction
is enable of UITabelView
. When you add any controller on UITableView
actually you added it on UITableViewCell
but cell is part of UITableView
so when you disable userInteraction
on UITableView
it means it aslo set it(NO) for UITableViewCell.
在这里,我也向您建议将UIButton
作为
And Here i aslo give you suggestion for add your UIButton
to cell as a
[cell.contentView addSubView:buttonName];
这篇关于如何禁用UITableview单元格的UserInteraction,但不能在单元格的自定义按钮中禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!