【发布时间】:2016-05-21 03:35:20
【问题描述】:
我的情况:我想在第 1 节中的索引 X 的一行中的索引 X 处保存数组中的数据。
我的代码是:
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return setObjectToPass.count
}
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Section \(section)"
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cellEmpty = tableView.dequeueReusableCellWithIdentifier("LabelCell")
var countCell = 0
while countCell < setObjectToPass.count {
let indexPaths = NSIndexPath(forRow: countCell, inSection: 0)
let cell = tableView.dequeueReusableCellWithIdentifier( "LabelCell", forIndexPath: indexPaths)
cell.textLabel!.text = String(setObjectToPass[countCell])
print(cell)
countCell+=1
return cell
}
我的问题是只有数组 SetObjectToPass 的第一个索引被传递并设置到 Cell.text
while counter < fetchResult?.count {
let set = fetchResult![counter]
counter+=1;
setObject.append((set.reps?.integerValue)!)
}
【问题讨论】:
-
我建议研究
UITableViewDataSource的基本实现。你在cellForRowAtIndexPath(_:)方法中所做的事情很奇怪。 -
好的,谢谢,我试试,还有什么建议吗?
-
setObjectToPass 数组值是什么?
-
这些是整数值
标签: ios arrays swift uitableview tableview