的UITableViewCell - 将其设置为选择/高亮...并保持选中/高亮
问题描述:
我想有一个UITableViewCell
一直亮着(蓝色),我称之为的UITableViewCell - 将其设置为选择/高亮...并保持选中/高亮
cell.selected = YES;
这可能后?我必须去了解它的另一种方式(如不cell.selected
)
答
假设你已经没有具体 的tableView didSelectRowAtIndexPath方法返回NO莫名其妙:indexPath,你不需要做任何事情,这是默认的行为。
答
您可以在选定的,像这样使用
[self tableView:self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForForRow:row inSection:section]];
答
您可以设置选择风格保持蓝色:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
}
,并确保您不会去选择单元格:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// This is what you DO NOT want to do
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
这实际上是默认行为。在什么情况下你有困难? – 2009-07-19 23:14:59