iphone - 如何禁用 UITableview 单元格的 UserInteraction 但不禁用单元格上的自定义按钮

标签 iphone objective-c uitableview

如何禁用 UITableview 单元格的 UserInteraction 但不是该单元格上的自定义按钮..

我正在使用 :

创建一个按钮
    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

最佳答案

不要禁用用户与整个单元格的交互。设置 cell.selectionStyle = UITableViewCellSelectionStyleNone 以防止单元格选择。这样用户仍然可以与按钮进行交互。

关于iphone - 如何禁用 UITableview 单元格的 UserInteraction 但不禁用单元格上的自定义按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17522953/

相关文章:

ios - 切换到 xcode 6 GM - 突然 Controller 不再符合 UITableViewDataSource

iphone - 从 Xcode 恢复删除的文件

ios - 如何向 NSPredicate 添加多个字段

objective-c - 从 Objective C 的头文件中隐藏实例变量

ios - UITableview 不通过 willdisplaycell 选择单元格

iOS7 表格索引显示为白色条

ios - 在 tableviewsource 上选择的 Monodevelop 行导致空引用异常

ios - 在 iOS 8 中使用 swift 将两个 View 分配给一个容器 View

iphone - 从 coredata 获取数据时出错?

iphone - 创建和取消 NSURLConnection