Swift 自定义 tableview 单元格没有我的图像 属性?
Swift custom tableview cell does not have my image property?
我正在尝试按照此视频的指南创建我自己的自定义 tableView 单元格
https://www.youtube.com/watch?v=EVJiprvRLoo
但是,当我执行 cell.photo.image 部分时,Xcode 告诉我 UITableViewCell 没有成员 'photo'
我是不是忘记连接什么东西了??
感谢大家的帮助!
您的问题将是 solved.youtube 视频指南是正确的,但请仔细观看直到结束。尝试下面的代码。 uiimageview 的照片属性不是 uiview。
class CustomCell: UITableViewCell {
@IBOutlet weak var photo: UIImageView!
@IBOutlet weak var name: UILabel!
@IBOutlet weak var breed: UILabel!
}
// Next class
class Dog: UIViewController,UITableViewDelegate,UITableViewDataSource {
func tableView(tableView: UITableView,numberOfRowsInSection section: Int) -> Int {
return Names.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomCell
cell.photo.image = images[indexPath.row]
我正在尝试按照此视频的指南创建我自己的自定义 tableView 单元格
https://www.youtube.com/watch?v=EVJiprvRLoo
但是,当我执行 cell.photo.image 部分时,Xcode 告诉我 UITableViewCell 没有成员 'photo'
我是不是忘记连接什么东西了??
感谢大家的帮助!
您的问题将是 solved.youtube 视频指南是正确的,但请仔细观看直到结束。尝试下面的代码。 uiimageview 的照片属性不是 uiview。
class CustomCell: UITableViewCell {
@IBOutlet weak var photo: UIImageView!
@IBOutlet weak var name: UILabel!
@IBOutlet weak var breed: UILabel!
}
// Next class
class Dog: UIViewController,UITableViewDelegate,UITableViewDataSource {
func tableView(tableView: UITableView,numberOfRowsInSection section: Int) -> Int {
return Names.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomCell
cell.photo.image = images[indexPath.row]