【发布时间】:2015-06-18 00:26:23
【问题描述】:
我已经四处寻找答案,但每个解决方案都会带来新的编译器错误。
如何为继承自 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)
}
...
}
修复错误:
编译器错误:
'UITableViewCellStyle.Type' is not convertible to 'UITableViewCellStyle'
【问题讨论】:
标签: ios uitableview swift initialization init