【发布时间】:2014-08-01 23:35:10
【问题描述】:
我有一个带有几个 IBOutlets 的自定义单元格类。我已将课程添加到情节提要中。我已经连接了我所有的插座。我的 cellForRowAtIndexPath 函数如下所示:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as SwipeableCell
cell.mainTextLabel.text = self.venueService.mainCategoriesArray()[indexPath.row]
return cell
}
这是我的自定义单元格类:
class SwipeableCell: UITableViewCell {
@IBOutlet var option1: UIButton
@IBOutlet var option2: UIButton
@IBOutlet var topLayerView : UIView
@IBOutlet var mainTextLabel : UILabel
@IBOutlet var categoryIcon : UIImageView
init(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
}
当我运行应用程序时,我的所有单元格都是空的。我已注销self.venueService.mainCategoriesArray(),它包含所有正确的字符串。我也尝试过放置一个与标签相等的实际字符串,这会产生相同的结果。
我错过了什么?任何帮助表示赞赏。
【问题讨论】:
-
我在一遍又一遍地寻找和挠头时遇到了同样的问题,然后从自定义单元格中删除了所有图像视图和标签,并使用新的约束重新设计了它。它工作得很好。因此,约束也可能是您的问题。先手动调整行大小,再添加组件
标签: swift uitableview cocoa-touch ios8 storyboard