[英]Cannot disable highlighting the first time UITableView selected?
我已经实现了cell.selectionStyle = UITableViewCellSelectionStyleNone;
同时在:
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { }
并在:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { }
但是每一行都会在第一次点击时保持蓝色选择。 如何完全禁用选择?
代码是这样的(单元格是自定义的):
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CategoryCell *cell = (CategoryCell*)[tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return nil;
}
在cellForRowAtIndexPath
实现它
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//create cell
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
关闭表格的“ allowsSelection
”属性 。
您可以以编程方式或在XIB / storyboard文件中执行此操作。
cell.selectionStyle = UITableViewCellSelectionStyleNone;
你应该在cellForRowAtIndexPath中做到这一点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.