在 iOS 9 中,uitableview 页脚文本对齐/间距发生了变化,我该怎么办?

Posted

技术标签:

【中文标题】在 iOS 9 中,uitableview 页脚文本对齐/间距发生了变化,我该怎么办?【英文标题】:In iOS 9 the uitableview footer text alignment/spacing changed, what can I do? 【发布时间】:2016-01-20 16:15:39 【问题描述】:

嘿嘿。

下面这两张图片显示了变化。这是我的代码,代码没有改变。

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

  if (section == 0) 
    return @"If enabled, closing apps via the app switcher won't actually close the app itself.\n\nThis option is perfect to use with Fast Freeze.";
  

  NSString *offDescription = @"OFF\nDisables the backgrounding capability completely. The app has to restart every time you close it.";
  NSString *fastFreezeDescription = @"FAST FREEZE\nThis mode is similar to what 'Smart Close' by rpetrich did. Usually an app has up to 10 minutes to perform tasks in the background before it gets suspended in memory. Since this can be an unnecessary battery drain, Fast Freeze will suspend the app right after you close it.";
  NSString *nativeDescription = @"NATIVE\nThis is Apple's built in way of backgrounding.";
  NSString *unlimitedNativeDescription = @"UNLIMITED NATIVE\nThis background mode allows apps to execute background tasks for an unlimited period of time, so the app won't get suspended in memory after 10 minutes.";
  NSString *foregroundDescription = @"FOREGROUND\nForeground tricks the system into thinking that the app wasn't closed and is still running in foreground. This is the perfect way to continue to listen to internet streams or videos while using another app.";

  return [NSString stringWithFormat:@"\n%@\n\n%@\n\n%@\n\n%@\n\n%@", offDescription, fastFreezeDescription, nativeDescription, unlimitedNativeDescription, foregroundDescription];

以下是截图:

这是之前的视图(ios 8),请注意“\nOFF\nDisables ...”与最后一个 UITableViewCell 的差距应该是这样。

这是(iOS 9)之后的视图,差距已关闭。空间太大了。

那么,有人知道为什么会这样吗?如果有人有修复或什么,请告诉我!

提前致谢!

【问题讨论】:

您是否配置了估计高度? 不,我没有这样做。 【参考方案1】:

这似乎是 Apple 的错误(iOS 9.0 - 9.1),页脚的行数越多,错位越大。

您甚至可以使用静态表格视图在情节提要中重现这一点。

我还没有找到任何解决方法,我能给的最好建议是file a bug report to Apple.


更新

情节提要中的错误似乎已在 Xcode 7.2 beta 2 中修复。但是,即使在 iOS 9.2 模拟器上运行应用程序时,此问题仍然存在。


更新 2

缩小了此错误的重现范围。基本上,在您的应用程序显示表格视图部分标题后,某些东西会中断。详情请查看this repo。

【讨论】:

感谢您的回答,iOS 9 似乎在他们宣布它时总体上更稳定了。 :p 我想我在 API 中找到了导致此错误的点,请检查第二次更新。这个错误非常令人不安。 好的,很高兴知道。如果您找到修复方法,也请告诉我。 该错误似乎在 iOS 10 beta 2 中已修复。

以上是关于在 iOS 9 中,uitableview 页脚文本对齐/间距发生了变化,我该怎么办?的主要内容,如果未能解决你的问题,请参考以下文章

如何在 UITableView 中制作最终页脚?

如何在 Storyboard 中向 UITableView 添加页脚

endUpdates 后的 UITableView 部分页脚视图位置

转 php include

如何在 TableView 的一个部分手动设置页脚(iOS)?

在 UITableView 中隐藏页脚视图