通过将行高设置为0来隐藏UITableView? [英] Hide a UITableView by setting row height to 0?

查看:56
本文介绍了通过将行高设置为0来隐藏UITableView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是继承了通过使用委托 heightForRowAtIndexPath 方法并为隐藏行"返回高度0来隐藏/显示行UITableView的代码.

I just inherited code which hides/shows rows a UITableView by using the delegate heightForRowAtIndexPath method and returning height 0 for "hidden rows".

该代码有效,但令我担心的是,其中可能充满不可预见的复杂性.有人可以缓解我的疑虑,也可以给我充分的理由为什么会引起问题(我在初始测试中找不到任何问题).

The code works, but it has me concerned there might be fraught with unforeseen complications. Can someone either ease my concerns or give me good reasons why this could cause problems (I couldn't find any issues with initial testing).

该表很小,总共不到10行,即使没有这种隐藏的行解决方案,也需要自定义行高.

The table is fairly small <10 rows total and would require custom row heights even without this hidden row solution.

推荐答案

在两个 beginUpdates endUpdates 调用之间添加和删除行会更干净,但是我不知道为什么这种0高度方法不起作用.

It would be cleaner to add and remove the rows between two beginUpdates and endUpdates calls, but I don't see why this 0-height method should not work.

如果没有UI工件,那就是(例如,显示为 Delete 的按钮溢出到下一个单元格.)

If there are no UI-artifacts, that is (e.g. the Delete button showing up overflowing to the next cell).

这篇关于通过将行高设置为0来隐藏UITableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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