Search code examples
iosswiftxcodetableviewios11

iOS 11 Extra top space in UITableView


When I updated my app on iOS 11 SDK , TableView started behaving Weird , It is adding extra top space , but actually that extra space is Cell itself but it is not rendered , please look through attached image before ios 11 update and after. Thank you!

this is after ios 11 update

Before ios 11


Solution

  • Set new property contentInsetAdjustmentBehavior in your code, it would fix the problem.

    if #available(iOS 11.0, *) {
        collectionView.contentInsetAdjustmentBehavior = .never
    }
    

    There is a new property on UIScrollView called contentInsetAdjustmentBehavior added in iOS 11 to determine adjust content offset

    This property specifies how the safe area insets are used to modify the content area of the scroll view. The default value of this property is automatic.