【发布时间】:2015-04-09 13:32:16
【问题描述】:
我正在尝试使用存储在 NSMutableArray 中的一些数据填充 UITableView(不确定它是否应该只是一个数组?)。
该表格由我在 Storyboard 中设计的自定义单元格组成,并给出了标识符:courseCell
为了尝试用我的 NSMutableArray 中的数据填充 UITableView,我使用了本教程:http://www.codingexplorer.com/getting-started-uitableview-swift/ 但是它达到了使用“cellForRowAtIndexPath”填充单元格的地步,但他们只是使用默认单元格样式,然后执行以下操作:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as UITableViewCell
let row = indexPath.row
cell.textLabel?.text = swiftBlogs[row]
return cell
}
但我正在使用一个有两个标签的自定义单元格。
我不知道该怎么做,所以我为标签和原型单元做了一个出口:
@IBOutlet var coursesTableView: UITableView!
@IBOutlet weak var customCell: UITableViewCell!
@IBOutlet weak var courseNameLabel: UILabel!
@IBOutlet weak var courseCodeLabel: UILabel!
我有点迷茫,不知道如何通过 cellForRowAtIndexPath 函数,将我的 NSMutableArray 数据加载到两个标签中。任何帮助将不胜感激!
注意:我只是 StackOverflow 的新手,如果我不够清楚,请告诉我。
【问题讨论】:
标签: ios uitableview swift nsmutablearray custom-cell