[英]Getting error Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) when loading AVPlayer
[英]Unable to setup UITableView cell programatically - thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
我正在尝试使用自动布局以编程方式设置UITableView单元,但是它一直崩溃,我不确定为什么会这样。 有人可以请教吗?
我正在尝试使用自动布局以编程方式设置UITableView单元,但是它一直崩溃,我不确定为什么会这样。 有人可以请教吗?
class FolderCell: UITableViewCell{
var jTitle: UILabel = {
let label = UILabel()
label.font = UIFont.italicSystemFont(ofSize: 12)
label.textColor = UIColor.gray
return label
}()
var date: UILabel = {
let label = UILabel()
label.font = UIFont.italicSystemFont(ofSize: 12)
label.textColor = UIColor.gray
return label
}()
var aTitle: UILabel {
let label = UILabel()
label.font = UIFont.boldSystemFont(ofSize: 15)
label.textColor = UIColor.gray
return label
}
var authors: UILabel = {
let label = UILabel()
label.font = UIFont.italicSystemFont(ofSize: 12)
label.textColor = UIColor.gray
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
cellSetup()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func cellSetup(){
contentView.addSubview(jTitle)
contentView.addSubview(aTitle)
contentView.addSubview(date)
contentView.addSubview(authors)
setUpLabels()
}
private func setUpLabels(){
jTitle.translatesAutoresizingMaskIntoConstraints = false
jTitle.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10).isActive = true
jTitle.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10).isActive = true
jTitle.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10).isActive = true
aTitle.translatesAutoresizingMaskIntoConstraints = false
aTitle.topAnchor.constraint(equalTo: jTitle.bottomAnchor, constant: 10).isActive = true
aTitle.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10).isActive = true
aTitle.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10).isActive = true
}
}
我遇到以下崩溃:
好像您没有启动aTitle标签。 使用它之前,请尝试将其初始化。
var aTitle: UILabel = {
let label = UILabel()
label.font = UIFont.boldSystemFont(ofSize: 15)
label.textColor = UIColor.gray
return label
}()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.