Add button to UITableViewCell

前端 未结 5 1661
一个人的身影
一个人的身影 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:49

    Try adding [cell.contentView addSubview:scanQRCodeButton]; or if you want the button to the left side look at my question at the answer, to move the textLabel to the side. If you want the button to the right then just set it as your accesoryView like this cell.accesoryView = scanQRCodeButton;.

提交回复
热议问题