Is it possible to disable floating headers in UITableView with UITableViewStylePlain?(是否可以使用 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 中的浮动标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以使用 UITableViewStylePlain 禁用 UITableView 中的浮动标题?


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01