隐藏UITableViewCell [英] Hiding UITableViewCell

查看:141
本文介绍了隐藏UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法隐藏一个UITableView单元格?我正在寻找一个属性或方法我可以调用UITableViewCell返回一个同步cellForRowAtIndexPath()来隐藏它,并使其不能被用户选择。

Is there a way to hide a UITableView cell? I'm looking for some property or method I can invoke on the UITableViewCell returned by a synchronous cellForRowAtIndexPath() to hide it and make it unselectable by the user.

推荐答案

对我来说使用映射并不容易,所以我决定使用SAS方法。但它不工作与我的自定义单元格。所以,我更正它:

For me using mapping is not easy way, so I decided to use SAS method. But it doesn't work with my custom cell. So, I correct it:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 7 && hide7Row){
        UITableViewCell* cell = [cells objectAtIndex:indexPath.row];
        cell.hidden = YES;
        return 0.0;
    }
    else if(indexPath.row == 8 && hide8Row){
        UITableViewCell* cell = [cells objectAtIndex:indexPath.row];
        cell.hidden = YES;
        return 0.0;
    }
    else {
        return 44.0;
    }
}

工作正常。

这篇关于隐藏UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆