How to reach the current selected cell in didSelectRowAtIndexPath?

前端 未结 6 1713
迷失自我
迷失自我 2021-02-01 00:10

I want to change the accessory view type of a cell through the method: didSelectRowAtIndexPath , i.e. when a row is selected I want to change the accessory view type, can I do t

6条回答
  •  感情败类
    2021-02-01 00:51

    In Swift 3.0 : You can use these 2 ways, according to your need

     let cell:UITableViewCell = tableView.cellForRow(at: indexPath) as UITableViewCell
    

    or

    let cell:CustomTableViewCell = tableView.cellForRow(at: indexPath) as! CustomTableViewCell
    

    Happy Coding !!

提交回复
热议问题