【发布时间】:2016-07-18 12:42:13
【问题描述】:
我正在尝试在 UITableViewCell 类中创建协议,但是当我声明我的委托时,required init?(coder aDecoder: NSCoder) 和 override init(style: UITableViewCellStyle, reuseIdentifier: String?) 都出现错误
错误:-Property 'self.delegate' not initialised at super.init
这是我的子类:-
import UIKit
protocol tableCellBtnActionDelegate{
func removeRowAtIndex(_: Int)
}
class FriendsListTableViewCell: UITableViewCell {
@IBOutlet weak var friendListAddBtn: UIButton!
var usersId : String!
var buttonText : String!
var indexPath : Int!
let delegate : tableCellBtnActionDelegate!
override func awakeFromNib() {
super.awakeFromNib()
friendListAddBtn.layer.cornerRadius = 4
friendListAddBtn.layer.backgroundColor = UIColor(red: 121.0/255.0, green: 220.0/255.0, blue: 1, alpha: 1).CGColor
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
}
【问题讨论】:
标签: ios swift uitableview swift-protocols