She*_*lam 64 iphone cocoa-touch objective-c uitableview
我有一个单元格,我插入到UITableView的顶部.如何确保当用户点击单元格时,它不会显示蓝色选定的指示符?
Joh*_*ang 70
将UITableViewCell的选择样式设置为UITableViewCellSelectionStyleNone
mal*_*hal 61
为了使单元格完全不可选,每个单元格需要两件事:
1-正如其他人所说:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Run Code Online (Sandbox Code Playgroud)
2-实现此委托方法如下:
// Called before the user changes the selection. Return a new indexPath, or nil, to change the proposed selection.
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
if(cell.selectionStyle == UITableViewCellSelectionStyleNone){
return nil;
}
return indexPath;
}
Run Code Online (Sandbox Code Playgroud)
Anj*_*nju 13
你可以做
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Run Code Online (Sandbox Code Playgroud)
小智 6
对于 Swift 3,您可以使用
cell.isUserInteractionEnabled = false
Run Code Online (Sandbox Code Playgroud)
Swift语法:
cell.selectionStyle = UITableViewCellSelectionStyle.None
Run Code Online (Sandbox Code Playgroud)
我是从禁用TableViewCell的角度回答的.您可以使用故事板.
XCode Version 8.2.1 (8C1002)
在故事板上选择TableVewCell,右侧面板上将显示以下内容 - Utilities.
进行选择:无
就这样!
小智 5
问题是如何使某些细胞可选择而其他细胞则不可选择。这是我的解决方案(在尝试了很多其他建议之后):
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
if (indexPath.row == 1 || indexPath.row == 2) {
return indexPath
}
return nil
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
33885 次 |
最近记录: |