可能重复:
How can I disable the UITableView selection highlighting?selectionStyle在iPhone UITableViewCell selectionStyle编辑时?
当您在一个UITableView
点按行,该行突出显示和选择。是否有可能禁用此功能,因此点击一行无能为力?
可能重复:
How can I disable the UITableView selection highlighting?selectionStyle在iPhone UITableViewCell selectionStyle编辑时?
当您在一个UITableView
点按行,该行突出显示和选择。是否有可能禁用此功能,因此点击一行无能为力?
是下面的代码将禁用用户交互,如果突出部分要禁用,你需要写一些,如果一些特定的细胞 - 别的方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.userInteractionEnabled = NO;
return cell;
}
这将防止细胞接收触摸事件,这可能不是他想要的。 –
好吧,如果你禁用用户交互,用户不能点击它:),并且他反正使用的可能是假账户 –
如果你有你的按钮或任何东西,还需要是“可触摸”,不仅仅是设置选择风格无:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
如果它只是一个文本比你可以像空间尘埃细胞建议。
已回答这个问题before。
抓住UITableViewCell
实例,并设置以下属性:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
你也可以试试这个:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//do ur stuff
}
DUP中的文章,我更喜欢低票的答案是设置allowsSelection =在tableView上的属性NO。 – danh
将'allowSelection'设置为'NO'是好的,但前提是您希望整个表视图具有不可选择的行。为了更好地控制单个单元格的选择性,可以使用'UITableViewCell'的'selectionStyle'属性。 – Pripyat