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

查看:474
本文介绍了是否可以使用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天全站免登陆