iOS 11浮动TableView标题 [英] iOS 11 Floating TableView Header

查看:93
本文介绍了iOS 11浮动TableView标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让应用程序使用多个部分,扩展时每个部分有几行,折叠时没有。每个部分都有一个部分标题,使用 UITableViewHeaderFooterView 等子类重用它们。到目前为止一切都很好。

Have an app going with multiple sections, a few rows per section when "expanded", none when "collapsed". Each section has a section header, was reusing them using a subclass of UITableViewHeaderFooterView etc. So far so good.

然后在iOS 11中:

Then in iOS 11:

描述问题的屏幕截图

我使用了可视调试器,并确认它是我的部分标题浮动。标题下方的所有行都正确显示,其他标题显示正常。

I've used the visual debugger, and confirmed it's my section header floating. All the rows beneath the header are displaying correctly, the other headers show fine.

为了恢复理智,我抛弃了标题的所有重用逻辑,并以编程方式编写它们。彼此彼此。 iOS 11之前的所有工作仍在iOS 11中浮动。浮动的部分似乎每次都会改变,所以就是这样。

In an effort to restore sanity, I threw out all of the reuse logic for the header and just made them programatically. Same same. All work pre-iOS 11, still float in iOS 11. The section which floats seems to change each time, so there's that.

任何想法?

推荐答案

刚遇到类似的问题,发现关于这个问题的讨论对我有用:

Just ran into a similar issue and found the discussion on this issue which worked for me:

self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;

似乎 UITableView 的默认行为已更改在iOS 11中使用估计的高度。 iOS 11 beta 2的发行说明说:

Seems like the default behavior of UITableView changed in iOS 11 to use estimated heights. The release notes for iOS 11 beta 2 say:


表视图现在默认使用估计的高度,这也意味着单元格和节标题/页脚视图现在默认为自我大小。 estimatedRowHeight,estimatedSectionHeaderHeight和estimatedSectionFooterHeight属性的默认值现在是UITableViewAutomaticDimension,这意味着表视图选择要使用的估计高度。如果可能,您仍应为每个房产提供更准确的估算,这是您对实际高度平均值的最佳猜测。如果现有的表视图代码在使用iOS 11 SDK构建应用程序时表现不同,并且您不想采用自行调整大小,则可以通过将值设置为零来禁用估计的高度来恢复以前的行为。每个估计的高度属性。 (30197915)

Table views now use estimated heights by default, which also means that cells and section header/footer views now self-size by default. The default value of the estimatedRowHeight, estimatedSectionHeaderHeight, and estimatedSectionFooterHeight properties is now UITableViewAutomaticDimension, which means the table view selects an estimated height to use. You should still provide a more accurate estimate for each property if possible, which is your best guess of the average value of the actual heights. If you have existing table view code that behaves differently when you build your app with the iOS 11 SDK, and you don’t want to adopt self-sizing, you can restore the previous behavior by disabling estimated heights by setting a value of zero for each estimated height property. (30197915)

另见beta 2发行说明在这里镜像

see also the beta 2 release notes mirrored here.

这篇关于iOS 11浮动TableView标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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