如何禁用UITableview单元格的UserInteraction,但不能在单元格的自定义按钮中禁用 [英] how to disable UserInteraction for UITableview cell but not in custom button on cell

查看:68
本文介绍了如何禁用UITableview单元格的UserInteraction,但不能在单元格的自定义按钮中禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁用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.当启用userInteractionuserInteraction时,您可以访问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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆