Add button to UITableViewCell's Accessory View

前端 未结 10 1959
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 16:41

Goal: when a user selects a cell, a button is added to that cell. Within my didSelectRowAtIndexPath function I have the following:

UIButton *downloadButton =         


        
10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-01 17:28

    Assign the button as the accessory view rather than a subview of the accessory view.

    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.accessoryView = downloadButton;
    

提交回复
热议问题