Я искал для ответа на это, но каждое решение просто приносит новые ошибки компилятора.Как установить инициализатор для пользовательского класса UITableViewCell?
Как настроить инициализаторы для класса, который наследуется от UITableViewCell?
Это то, что я до сих пор, любая помощь будет принята с благодарностью:
SettingCell.swift
class SettingCell: UITableViewCell {
@IBOutlet weak var settingsLabel: UILabel!
@IBOutlet weak var settingsSwitch: UISwitch?
@IBOutlet weak var timeSetting: UILabel?
var cellDelegate: SettingCellDelegate?
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
init(settingLabel: UILabel!, settingSwitch: UISwitch?, timeSetting: UILabel?) {
super.init(style: UITableViewCellStyle, reuseIdentifier: String?)
self.settingsLabel = settingLabel
self.settingsSwitch = settingSwitch
self.timeSetting = timeSetting
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@IBAction func handledSwitchChange(sender: UISwitch) {
self.cellDelegate?.didChangeSwitchState(sender: self, isOn:settingsSwitch!.on)
}
...
}
Fix-It Ошибка:
Ошибка компилятора:
'UITableViewCellStyle.Type' is not convertible to 'UITableViewCellStyle'
благодарит за Wain ответа, вот ошибка, компилятор возвращается, когда я использую вашу подпись: «UITableViewCellStyle.Type» не имеет члена с именем «UITableViewCellStyleDefault» –
ok, он просто изменил его на: super.init (style: .Default, reuseIdentifier: «SettingCell») –
Простите, что была obj-c версия enum – Wain