我使用IB并取消选中“显示触摸选择”,但它仍然在选定的单元上显示蓝色突出显示。这是苹果的错误还是我错了。当禁用显示选择触摸UITableview时出现问题?
7
A
回答
19
这可能是IB中的一个错误,正如您在文档中看到的那样,表格视图没有任何属性可用于触摸显示选择。它是tableview单元格的属性。所以复选框不应该出现在IB中。可能你可以用苹果提交一个bug,看看他们对它的评价。
为了得到效果,你应该这样做,如:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
}
希望这有助于。
0
我也觉得这很可能是一个错误。但是,我只是基于以下观察找到了一个完美的解决方法。
- The cell is
highlighted
on touch down andselected
on touch up。 -setHighlighted:animated:
和-setSelected:animated:
都会根据其选择样式突出显示该单元格,即将其中任意一个打开而另一个打开则会突出显示该单元格。- 电池诞生时
highlighted
关闭(通常,否则下面的解决方案只需要根据您的具体情况很容易找出适当的调整)。
鉴于上述情况,只要继承的UITableViewCell和覆盖setHighlighted:animated:
,而无需调用super
的实现。因此,所有打开highlighted
的努力都将被抑制,突出显示只会在触摸时发生,而不是在触摸时发生,这正是关闭“显示选择时触摸”的预期结果。
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
// hack to get the effect of unchecking "Show Selection on Touch" option of UITableView in IB which has no effect
}
在触摸时,该小区是selected
但它不是animated
。如果你想要动画,我发现调用如下所示的委托方法可以动画选择。
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[_itemsTable selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
return indexPath;
}
相关问题
- 1. UITableView - 选择时出现问题
- 2. 当图像被触摸时显示UIButton?
- 3. Swift 3:当用户触摸textView的光标时发出问题
- 4. EditText触摸时没有突出显示
- 5. UITableView和触摸节标题
- 6. 突出显示UITableView没有选择
- 7. 选择查询时出现问题
- 8. 当试图突出显示ListView行项onClick时出现问题
- 9. UIImageView触摸时显示UIAlert
- 10. 暂时禁用CCLayerPanZoom触摸
- 11. 如何禁用触摸UIBarButtonItem时出现的光?
- 12. 使用JLabel显示选择的图像文件时出现的问题
- 13. Sencha触摸DataView并选中时突出显示一行
- 14. iPad使用触摸来显示弹出?
- 15. 显示控件时出现问题
- 16. Android:显示文本时出现问题
- 17. 按钮栏选择的问题,当禁用切换时?
- 18. 当用户触摸已选择的行时,如何隐藏UIPIckerView
- 19. 在模式窗口中显示错误,当出现问题时
- 20. 在UITableView中显示的UIWebView内接触的触摸
- 21. 完全禁用Android GridView突出显示(禁用选择)
- 22. 当用户触摸图像时出现文字
- 23. 禁用uitableview突出显示,但允许选择单个单元格
- 24. 问题,同时禁用滚动的UITableview
- 25. 当用户选择UITextField时显示UIPicker
- 26. 当我触摸TextView时触摸按钮
- 27. 使用JQuery选择单选按钮时出现问题
- 28. 当用户触摸屏幕时显示圆圈Javascript
- 29. 选择禁用的ListBox项目时显示禁用的原因
- 30. Android触摸问题