Issue:我只想显示带有复选标记的选定单元格。我不想要灰色的亮点。 我试过了:UITableView:选中具有复选标记但没有高亮的行
cell.selectionStyle = UITableViewCellSelectionStyleNone
但没有奏效。
下面是代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
ProfileSelection *profile = [self.profileSelections objectAtIndex:indexPath.row];
cell.textLabel.text = [profile profileName];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.profileSelectionsTableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
ProfileSelection *profile = [self.profileSelections objectAtIndex:indexPath.row];
self.mobileProfileId = [profile.profileId stringValue];
[_continueButton setEnabled:YES];
}
你试过了什么?你在哪里使用了selectionStyle? – NSPunk
'selectionStyle'是合适的属性。如果它不起作用,你把它放在错误的地方。向我们显示您输入的方法的代码。 – Dima
尝试在单元格分配后添加行'cell.selectionStyle = UITableViewCellSelectionStyleNone;'if'块内部。 – itsji10dra