2 lpploverou LPPloveROU 于 2013.07.09 15:21 提问

禁用UserInteraction

怎么禁用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?

1个回答

zhanglei5415
zhanglei5415   Rxr 2013.07.09 16:40
已采纳

尝试设置

cell.selectionStyle=UITableViewCellSelectionStyleNone;

响应动作

[dayButton addTarget:self action:@selector(selectDayView:) forControlEvents:UIControlEventTouchUpInside];
    -(void)selectDayView:(id)sender  {
         /////to do ....
    }
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!