2016-06-28 127 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

相關問題