2016-06-28 130 views
1

我想按照这个视频指南上创建自己的自定义的tableView细胞Swift自定义tableview单元格没有我的图像属性?

https://www.youtube.com/watch?v=EVJiprvRLoo

然而,当我做cell.photo.image部分,Xcode中告诉我的UITableViewCell没有成员的照片'

我忘了将某物连接到某处吗?

感谢您的帮助!

+0

你忘了在'CustomCell'中创建'UIImageView'的'outlet'。创建并使用'prototypeCell'绑定它。它会解决你的问题。 –

回答

1

您的问题将得到解决.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] 
+0

谢谢!当我宣布我的单元格变量时,我看到了我做错了什么! – user3175707

相关问题