【问题标题】:Tableview section appearing after deleting all rows deleted from section删除从部分删除的所有行后出现的 Tableview 部分
【发布时间】:2015-03-04 06:43:00
【问题描述】:

我有一个 tableview,它有 2 个部分。基于 numberOfRowsInsection,viewForHeaderInSection 中的 sectionheaderview 设置。这个视图来自 xib。现在我的问题是从任何部分删除所有行后,标题视图仍然出现,尽管在 heightForHeaderInSection 中传递 0.0f,并从 viewForHeaderInSection 返回 nil 值。

谢谢

【问题讨论】:

    标签: ios uitableview


    【解决方案1】:

    只需在 heightForHeaderInSection 中传递 1.0。

    【讨论】:

    • 默认我通过 0.f
    • - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { CGFloat height = 0.0f; if (section == 0) { if ([myItems1 count]) { height = 45.0; } } else { if ([myItems count]) { height = 45.0; } } 返回高度; }
    • -(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.f, 0.f,320. f,22.f)]; [查看 setBackgroundColor:[UIColor redColor]]; if (section ==0 &&[myItems1 count]==0) { view = nil; } else if (section ==1 &&[myItems1 count]==0) { view = nil; } 返回视图;
    • 请告诉我是什么问题
    • 用这个改变方法-
    猜你喜欢
    • 1970-01-01
    • 2013-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 1970-01-01
    相关资源
    最近更新 更多