如何在不禁用突出显示的情况下禁用合适的触摸行

Posted

技术标签:

【中文标题】如何在不禁用突出显示的情况下禁用合适的触摸行【英文标题】:How to disable touch row in uitable without disable highlight 【发布时间】:2014-03-12 16:28:20 【问题描述】:

在 UITable 中,我获取所选行的索引。当我获得行索引时,我想禁用她,然后它不能被按下,但突出显示应该保留。当我点击另一行时,它是高亮的,前一行是启用的,高亮是禁用的。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    CellIndex = indexPath.row;
    [self.containerViewController swapViewControllers:CellIndex];

如果您单击已按下的行,我希望什么都不会发生。 谢谢大家的帮助。

【问题讨论】:

【参考方案1】:

保留一个知道最后按下哪一行的变量,并签入tableView:didSelectRowAtIndexPath:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    if(previouslySelectedIndexPath == indexPath)
        return;
    previouslySelectedIndexPath = indexPath;

    CellIndex = indexPath.row;
    [self.containerViewController swapViewControllers:CellIndex];

【讨论】:

非常感谢,对您有帮助。

以上是关于如何在不禁用突出显示的情况下禁用合适的触摸行的主要内容,如果未能解决你的问题,请参考以下文章