I'm creating a settings page for my Swift app and (following examples here on SO) I've subclassed a UITableViewCell
and in the init()
handlers I've set the accessoryView
to be a UISwitch()
.
I also have a custom @IBInspectable
property on the subclass which is also marked @IBDesignable
:
@IBDesignable class TableViewSwitchCell: UITableViewCell {
@IBInspectable var settingsKey: String?
func build()
{
accessoryView = UISwitch()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
build()
}
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
build()
}
// code omitted that uses the settingsKey with NSUserDefaults
}
How can I arrange for the UISwitch
to also be visible in InterfaceBuilder so that I can attach additional targets to it whilst still just subclassing from UITableViewCell
Ideally I don't want to create a whole new nib with its own layout, since I still want to retain most of the other features of a standard UITableViewCell
.