Kun*_*Das 5 segmentation-fault ios swift swift2 swift3
彻底搜索了这个问题,但无法在Stack Overflow中找到它.
获取分段错误错误:
1. While type-checking getter for asset at <invalid loc>
Run Code Online (Sandbox Code Playgroud)
下面是我得到分段错误的类的代码 -
import UIKit
class WidgetImageTableViewCell: UITableViewCell {
@IBOutlet weak var imgViewWidget: UIImageView!
var aspectConstraint : NSLayoutConstraint!
{
didSet {
if oldValue != nil {
imgViewWidget.removeConstraint(oldValue!)
}
if aspectConstraint != nil {
imgViewWidget.addConstraint(aspectConstraint!)
}
}
}
override func prepareForReuse() {
super.prepareForReuse()
aspectConstraint = nil
}
func setPostedImage(image : UIImage) {
let aspect:CGFloat = image.size.width/image.size.height
aspectConstraint = NSLayoutConstraint(item: imgViewWidget, attribute: .width, relatedBy: .equal, toItem: imgViewWidget, attribute: .height, multiplier: aspect, constant: 0.0)
imgViewWidget.image = image
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
131 次 |
| 最近记录: |