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

查看:25
本文介绍了是否可以使用 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,有没有办法做到这一点?我想避免使用 grouped,因为它会为我的所有单元格添加一个边距,并且需要禁用每个单元格的背景视图.我想完全控制我的布局.理想情况下,它们应该是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天全站免登陆