Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable UserInteraction for UITableview cell but not in custom button on cell

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];

and then I set

    cell.userInteractionEnabled=NO;

how can I get dayButtonAction ?

like image 941
sai Avatar asked Jul 08 '13 09:07

sai


2 Answers

Don't disable user interaction with the whole cell. Set cell.selectionStyle = UITableViewCellSelectionStyleNone to prevent the cell selection. That way the user can still interact with the button.

like image 137
Engin Kurutepe Avatar answered Sep 22 '22 23:09

Engin Kurutepe


If you set the cell.userinteraction = NO then you can't touch the button because any interaction is closed for the cell and it's subviews.

like image 31
soryngod Avatar answered Sep 23 '22 23:09

soryngod