Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton also highlighting when cell is touched

I've a UIButton on my table cell that pops up (touchUpInside) a UIAlertView and asks the user if they want to delete the file associated with that cell. Otherwise, a touch on the cell itself highlights the cell then moves to the next level to reveal content. The issue is that when the cell is selected and highlighted, the button highlights as well, confusing the user.

How can I tell the button to ignore touches to the cell or tell the cell to leave the damn button alone.

like image 744
Michael Morrison Avatar asked Feb 02 '26 09:02

Michael Morrison


1 Answers

I tried this workaround with mixed results. While it will return the button to its normal state, there is a brief flicker as it changes from normal, to selected, and back to normal again.

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    CustomCell *cell = (CustomCell *)[tableView cellForRowAtIndexPath:indexPath];
    cell.button.highlighted = NO;
}
like image 196
Brandon Avatar answered Feb 04 '26 23:02

Brandon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!