2012-01-18 68 views

回答

1

以我的经验,@ Ali3n的解决方案不起作用view.userInteractionEnabled = NO )。当您点击视图时,单元格仍处于选中状态。

但是,我发现,如果你添加一个UIButton作为子视图,并添加你的子视图,那么它的确如你所期望的那样工作 - 即你点击按钮覆盖的区域, 未选择。 如果您使用自定义样式的UIButton,那么无论如何它看起来都不像普通的UIView。

下面是我如何添加一个UISwitch到accessoryView,后面有一个不可抽出的UIButton。如果您错过了按钮并点击了背景,则单元格将被选中而不是

UIButton* button =[UIButton buttonWithType:UIButtonTypeCustom]; 
button.frame = CGRectMake(0, 0, 100, 67); 
self.accessoryView = button; 
self.accessoryView.backgroundColor = [UIColor grayColor]; 
UISwitch* statusSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 20, 80, 40)]; 
[self.accessoryView addSubview:statusSwitch]; 
1

你可以在这些意见中禁用用户互为作用使用userInteractionEnabled属性: - (即使用

view.userInteractionEnabled = NO; 
+0

是的,做到了,但同样的问题。恐怕与后面的表单元格有关。 – 2012-01-18 21:04:19

相关问题