Table 使用 Class 在故事板中查看控制器
Table View Controller in storyboard with Class
我在故事板中添加了一个 Table 视图控制器。然后我将 Table View Controller 的 Class 设置为我的 class 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
类型的值
如何访问 TableViewController class 中的 dequeueReusableCellWithIdentifier?难道我不能使用 self.dequeueReusableCellWithIdentifier 因为我已经在 Storyboard 中设置了 class 吗?
dequeueReusableCellWithIdentifier
是 不是 UITableViewController
方法。是UITableView
方法
所以,你需要
let cell = tableView.dequeueReusableCellWithIdentifier("subscriptionCell") as! SubscriptionsTableViewCell
先检查documentation。
请务必将 SubscriptionsTableViewCell
注册为 table 视图的单元格 class。
我在故事板中添加了一个 Table 视图控制器。然后我将 Table View Controller 的 Class 设置为我的 class 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
如何访问 TableViewController class 中的 dequeueReusableCellWithIdentifier?难道我不能使用 self.dequeueReusableCellWithIdentifier 因为我已经在 Storyboard 中设置了 class 吗?
dequeueReusableCellWithIdentifier
是 不是 UITableViewController
方法。是UITableView
方法
所以,你需要
let cell = tableView.dequeueReusableCellWithIdentifier("subscriptionCell") as! SubscriptionsTableViewCell
先检查documentation。
请务必将 SubscriptionsTableViewCell
注册为 table 视图的单元格 class。