Add button to UITableViewCell's Accessory View

前端 未结 10 1937
没有蜡笔的小新
没有蜡笔的小新 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条回答
  •  萌比男神i
    2021-01-01 17:27

    Swift

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
        let accessoryButton = UIButton.buttonWithType(UIButtonType.ContactAdd) as! UIButton
        cell.accessoryView = accessoryButton
    
        return cell
    }
    

提交回复
热议问题