是否可以使用 UITableViewStylePlain 禁用 UITableView 中的浮动标题? [英] Is it possible to disable floating headers in UITableView with UITableViewStylePlain?

查看:15
本文介绍了是否可以使用 UITableViewStylePlain 禁用 UITableView 中的浮动标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UITableView 来布局内容页面".我正在使用表格视图的标题来布局某些图像等,如果它们不浮动但保持静态,就像在样式设置为 UITableViewStyleGrouped 时一样,我更喜欢它.

I'm using a UITableView to layout content 'pages'. I'm using the headers of the table view to layout certain images etc. and I'd prefer it if they didn't float but stayed static as they do when the style is set to UITableViewStyleGrouped.

然后使用 UITableViewStyleGrouped,有没有办法做到这一点?我想避免使用分组,因为它会在我的所有单元格中添加一个边距,并且需要禁用每个单元格的背景视图.我想完全控制我的布局.理想情况下,它们是UITableViewStyleBareBones",但我在文档中没有看到该选项...

Other then using UITableViewStyleGrouped, is there a way to do this? I'd like to avoid using grouped as it adds a margin down all my cells and requires disabling of the background view for each of the cells. I'd like full control of my layout. Ideally they'd be a "UITableViewStyleBareBones", but I didn't see that option in the docs...

非常感谢,

推荐答案

您应该能够通过使用自定义单元格来制作标题行来伪造它.然后这些将像表格视图中的任何其他单元格一样滚动.

You should be able to fake this by using a custom cell to do your header rows. These will then scroll like any other cell in the table view.

您只需要在您的 cellForRowAtIndexPath 中添加一些逻辑,以在它是标题行时返回正确的单元格类型.

You just need to add some logic in your cellForRowAtIndexPath to return the right cell type when it is a header row.

您可能必须自己管理您的部分,即将所有内容放在一个部分中并伪造标题.(您也可以尝试为标题视图返回一个隐藏视图,但我不知道这是否可行)

You'll probably have to manage your sections yourself though, i.e. have everything in one section and fake the headers. (You could also try returning a hidden view for the header view, but I don't know if that will work)

这篇关于是否可以使用 UITableViewStylePlain 禁用 UITableView 中的浮动标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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