Add button to UITableViewCell

前端 未结 5 1700
一个人的身影
一个人的身影 2021-02-03 15:07

I want to add a button in a UITableViewCell. This is my code: `

if (indexPath.row==2) {
    UIButton *scanQRCodeButton = [[UIButton alloc]init];

           


        
5条回答
  •  無奈伤痛
    2021-02-03 15:48

    You want to add any custom UI elements to the cell's contentView.

    So, instead of [cell addSubview:scanQRCodeButton];
    do [cell.contentView addSubview:scanQRCodeButton];

提交回复
热议问题