UISwitch in a UITableView cell

前端 未结 6 1600
生来不讨喜
生来不讨喜 2020-11-30 21:57

How can I embed a UISwitch on a UITableView cell? Examples can be seen in the settings menu.

My current solution:

6条回答
  •  忘掉有多难
    2020-11-30 23:01

    for swift users

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            let cell = UITableViewCell(style: .default, reuseIdentifier: "TableIdentifer")
            let switch = UISwitch()
            cell.accessoryView = switch 
    }
    

提交回复
热议问题