简体   繁体   English

iOS 11在带有静态单元格的UITableViewController中的表视图上差距20分

[英]iOS 11 20 points gap over tableview in UITableViewController with static cells

在此处输入图片说明

I have been using a UITableViewController in my app. 我一直在我的应用程序中使用UITableViewController。 It worked fine in iOS 10.xx but I recently upgraded my Xcode and iOS to (Xcode 9 and iOS 11). 在iOS 10.xx上运行正常,但最近我将Xcode和iOS升级到了(Xcode 9和iOS 11)。 Then the my app is having this UI issue. 然后我的应用出现此UI问题。 It will show a 20 points gap above the UITableView in a UITableViewController with static cells. 在带有静态单元格的UITableViewController中,它将在UITableView上方显示20点的差距。 Anyone having same problem and found the solution for this? 任何有相同问题的人都找到了解决方案?

It is due to the new property introduced in iOS 11. Try the following: 这是由于iOS 11中引入了新属性。请尝试以下操作:

if #available(iOS 11.0, *) {
    tableView.contentInsetAdjustmentBehavior = .never
} else {
    automaticallyAdjustsScrollViewInsets = false
}

chengsam 's answer works perfectly to solve this problem. chengsam的答案非常适合解决此问题。

If you want to accomplish the iOS 11 part in Interface Builder, you can do so. 如果要在Interface Builder中完成iOS 11部分,可以这样做。 It's available in the Size Selector in the Utilities View. 在“实用工具”视图的“大小选择器”中可用。

IB内容插入属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM