我的代码中不断出现此错误,它说 UIView 类型的值没有成员。
这是代码。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: CellLemon = tableView.dequeueReusableCellWithIdentifier("Cell") as! CellLemon
cell.cellTopLabel.text = CarMake[indexPath.row]
cell.cellBottom.text = CarModel[indexPath.row]
var imageName = UIImage(named: CarImage[indexPath.row])
cell.cellImage.image = imageName
// Configure the cell...
return cell
}
有问题的代码是这样的,
cell.cellImage.image = imageName
这是 cellLemon 类。这正是你们所要求的。
import UIKit
class CellLemon: UITableViewCell {
@IBOutlet weak var cellImage: UIView!
@IBOutlet weak var cellTopLabel: UILabel!
@IBOutlet weak var cellBottom: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
最佳答案
你错了。请仔细检查并修复它
@IBOutlet weak var cellImage: UIView! // why cellImage is UIView?
关于ios - 类型 UIView 的值没有成员错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35859175/