返回UITableView节头的CGFloat.leastNormalMagnitude会导致崩溃
我为iOS 8制作了一个应用程序,它为其中一个页面使用了分组 UITableView
。其中有多个部分使用 CGFloat.leastNormalMagnitude
(或Swift 2及以下的 CGFloat.min
)页眉和页脚高度删除默认空格。一切顺利,直到应用程序在iOS 9和10中运行,它崩溃时出现此错误:
I made an app for iOS 8 which uses grouped UITableView
for one of its page. There are multiple sections in it that uses CGFloat.leastNormalMagnitude
(or CGFloat.min
in Swift 2 and below) for section header and footer height to remove the "default" space. Everything went well until the app run in iOS 9 and 10, where it crashes with this error:
因未捕获的异常而终止应用程序'NSInternalInconsistencyException ',原因:'部分标题高度不得为负 - 提供第0部分的高度为-0.00000'
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'section header height must not be negative - provided height for section 0 is -0.00000'
不知何故,任何值都在 1
(舍入的 0
除外)被视为否定 - 并使用 1
作为返回值将使页眉/页脚空间再次出现。
Somehow, any value under 1
(except the rounded 0
) is treated as a negative - and using 1
as return value will make the header / footer space appears again.
是否有任何解决方法可以解决此问题?
Is there any workaround to fix this?
提前致谢。
我尝试了几个值 tableView(_:heightForHeaderInSection:)
,并发现:
I have tried several values for the tableView(_:heightForHeaderInSection:)
, and found out that:
-
leastNormalMagnitude
和leastNonzeroMagnitude
将被视为减号(因此崩溃)。 - 零将使TableView返回默认高度作为页眉/页脚。
- 零和一之间的任何内容都将被视为减号。
- 一个将使TableView返回默认高度。
- 任何多于一个(例如1.1)都会将页眉/页脚设置为实际高度。
-
leastNormalMagnitude
andleastNonzeroMagnitude
will be treated as minus (hence the crash). - Zero will make the TableView return the default height as header / footer.
- Anything between zero and one will be treated as a minus.
- One will make the TableView return the default height.
- Anything more than one (e.g 1.1) will set the header / footer to the actual height.
我最终使用 1.1
来解决我的问题。
I ended up using 1.1
for solving my problem.
希望这将有助于那里的人!
Hope this will help someone out there!