在为某些数组值选择之前,我必须先显示复选标记,然后必须显示数组值1的复选标记和0的无复选标记。如何做that..check下面的代码:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.textLabel?.text = AllItems[indexPath.row] as? String
for dict1 in selectedItems
{
if Intvalues == dict1 as? NSObject {
// I have to show CheckMark
}
else if ZeroIntvalues == dict1 as? NSObject
{
// I don’t need to show CheckMark
}
}
cell.textLabel?.textColor = UIColor.whiteColor()
return cell
}发布于 2016-11-24 09:27:09
“因为原因,”Paulw11 11说,“您的代码是错误的。每个tableViewCell都会显示复选标记,因为for循环的最后一个对象总是1。
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.textLabel?.text = AllItems[indexPath.row] as? String
if Intvalues == AllItems[indexPath.row] as? Int {
// I have to show CheckMark
cell.accessoryType = .Checkmark
} else {
cell.accessoryType = .None
}
cell.textLabel?.textColor = UIColor.whiteColor()
return cell
}发布于 2016-11-24 09:20:46
Tableview单元格有附件类型,在tableviewCellForRowAtIndexPath中使用此类型
cell.accessoryType = UITableViewCellAccessoryCheckmark;发布于 2016-11-24 09:21:16
您在下面显示支票标记。
cell.accessoryType = .None
if Intvalues == dict1 as? NSObject {
// I have to show CheckMark
cell.accessoryType = .Checkmark
}https://stackoverflow.com/questions/40782238
复制相似问题