2015-10-06 111 views
1

我向故事板添加了一個表視圖控制器。然後我將桌面視圖控制器的類設置爲我的類SubscriptionsTableViewController: UITableViewController帶有類別的故事板中的表視圖控制器

現在我想用我製作的單元格填充它。

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = self.dequeueReusableCellWithIdentifier("subscriptionCell") as! SubscriptionsTableViewCell 
return cell 

這給了我型SubscriptionsTableViewController has no member dequeueReusableCellWithIdentifier

的價值如何訪問的dequeueReusableCellWithIdentifier在TableViewController類?我應該不能使用self.dequeueReusableCellWithIdentifier,因爲我已經在Storyboard中設置了類。

回答

2

dequeueReusableCellWithIdentifier不是UITableViewController方法。這是UITableView方法

所以,你需要

let cell = tableView.dequeueReusableCellWithIdentifier("subscriptionCell") as! SubscriptionsTableViewCell 

檢查documentation第一。

務必將SubscriptionsTableViewCell註冊爲您的表格視圖的單元類。

+0

隨意問,如果有什麼不清楚的話 –

+0

也要在故事板中添加「subscriptionCell」作爲單元標識符 –

相關問題