diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.m b/SignalMessaging/ViewControllers/OWSTableViewController.m index ae43fb1ec..44fe661b5 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.m +++ b/SignalMessaging/ViewControllers/OWSTableViewController.m @@ -453,10 +453,21 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier"; self.tableView.dataSource = self; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; - [self.tableView applyScrollViewInsetsFix]; - [self.view addSubview:self.tableView]; - [self.tableView autoPinEdgesToSuperviewEdges]; + + if ([self.tableView applyScrollViewInsetsFix]) { + // if applyScrollViewInsetsFix disables contentInsetAdjustmentBehavior, + // we need to pin to the top and bottom layout guides since UIKit + // won't adjust our content insets. + [self.tableView autoPinToTopLayoutGuideOfViewController:self withInset:0]; + [self.tableView autoPinToBottomLayoutGuideOfViewController:self withInset:0]; + [self.tableView autoPinWidthToSuperview]; + + // We don't need a top or bottom insets, since we pin to the top and bottom layout guides. + self.automaticallyAdjustsScrollViewInsets = NO; + } else { + [self.tableView autoPinEdgesToSuperviewEdges]; + } [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kOWSTableCellIdentifier]; diff --git a/SignalMessaging/categories/UIView+OWS.h b/SignalMessaging/categories/UIView+OWS.h index 59f27e268..e661f64ea 100644 --- a/SignalMessaging/categories/UIView+OWS.h +++ b/SignalMessaging/categories/UIView+OWS.h @@ -134,7 +134,8 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value); @interface UIScrollView (OWS) -- (void)applyScrollViewInsetsFix; +// Returns YES if contentInsetAdjustmentBehavior is disabled. +- (BOOL)applyScrollViewInsetsFix; @end diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index 067e37810..a55cf0371 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -519,7 +519,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) @implementation UIScrollView (OWS) -- (void)applyScrollViewInsetsFix +- (BOOL)applyScrollViewInsetsFix { // Fix a bug that only affects iOS 11.0.x and 11.1.x. // The symptom is a fix weird animation that happens when using the interactive pop gesture. @@ -528,7 +528,9 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) #pragma clang diagnostic ignored "-Wpartial-availability" self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; #pragma clang diagnostic pop + return YES; } + return NO; } @end