У меня есть пользовательский подкласс UITableViewCell с простой установкой IBOutlet для UILabel.Пользовательский UITableviewCell IBOutlet всегда nil
class SegmentCell: UITableViewCell {
@IBOutlet weak var test: UILabel!
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
test.text = "Some Text"
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Убежденный, что все правильное настроено, соответствовало другим ответам, но UILabel всегда ноль.
ViewController: viewDidLoad:
self.tableView.registerClass(SegmentCell.self, forCellReuseIdentifier: "Cell")
cellForForAtIndexPath
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! SegmentCell
return cell
}
- Сотовый установлено значение Пользовательский идентификатор
- Повторное использование является правильным класса
- клеток SegmentCell
- Содержание таблиц - это динамические прототипы
Что мне не хватает?
Вам не нужны называть self.tableView.registerClass (SegmentCell.self, forCellReuseIdentifier: "Cell") на viewDidLoad, просто установите prototypeCells класса на «SegmentCell» на Mainstoryboard. –