How can I embed a UISwitch
programmatically in a tableView cell in Swift?
I'm doing it like that
let shareLocationSwitch = UISwitch()
cell.accessoryView = shareLocationSwitch
How can I embed a UISwitch
programmatically in a tableView cell in Swift?
I'm doing it like that
let shareLocationSwitch = UISwitch()
cell.accessoryView = shareLocationSwitch
Here is way you can embed a
UISwitch
on aUITableView
cell.here is switch call beck method
Note: if your
tableview
may have more than onesection
then You should create a CustomCell subclassingUITableViewCell
and configure youraccessoryView
insideUITableViewCell
awakeFromNib
method instead of table viewcellForRowAt
method. When dequeuing the reusablecell
cast it to your CustomCell Here is sample from @LeoDabus