I want to add a button in a UITableViewCell. This is my code: `
UITableViewCell
if (indexPath.row==2) { UIButton *scanQRCodeButton = [[UIButton alloc]init];
You want to add any custom UI elements to the cell's contentView.
contentView
So, instead of [cell addSubview:scanQRCodeButton]; do [cell.contentView addSubview:scanQRCodeButton];
[cell addSubview:scanQRCodeButton];
[cell.contentView addSubview:scanQRCodeButton];