[英]no idea why “label” popped up when I tap the cell table
点击单元格后,我不明白为什么在UITableView
点击单元格时,为什么会不断弹出“标签”一词
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
cell.textLabel?.text = categories[indexPath.row]
cell.imageView?.image = normal_icons[indexPath.row]
return cell
}
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath)
cell?.accessoryType = UITableViewCellAccessoryType.None
cell?.textLabel?.textColor = UIColor.blackColor()
cell?.imageView?.image = normal_icons[indexPath.row]
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath)
cell?.accessoryType = UITableViewCellAccessoryType.Checkmark
cell?.textLabel?.textColor = UIColor.blueColor()
cell?.imageView?.image = active_icons[indexPath.row]
cell!.detailTextLabel?.text = " "
}
表格单元格类型为
更改
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)
至
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
注意您做了Deselect RowAtIndexPath和Select RowAtIndexPath
但我相信,即使将didDeselect更改为didSelect之后,它还会有更多问题
您是否要在didSelectRowAtIndexPath中更改detailTextLabel? 那可能是问题所在。 尝试将其设置为空字符串以确认是否确实是问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.