为什么selectionStyle没有效果?
问题描述:
cellForRowAtIndexPath
返回带有selectionStyleBlue
的单元格。但它没有效果。选择行时使用灰色选择样式。任何想法为什么?为什么selectionStyle没有效果?
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
答
试试这个。
//泰伯维委托方法...
倍率FUNC的tableView(的tableView:UITableView的,didSelectRowAtIndexPath方法indexPath:NSIndexPath){
var selectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
selectedCell.contentView.backgroundColor = UIColor.redColor()
}
倍率FUNC的tableView(的tableView:UITableView的, didDeselectRowAtIndexPath indexPath:NSIndexPath){
var cellToDeSelect:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
cellToDeSelect.contentView.backgroundColor = colorForCellUnselected
}
请检查用户交互是否启用tableview/tableviewcell – Ujesh
我认为它在选择行时返回灰色颜色? – Birendra
**选择**行时使用灰色。 –