ios 11 上tableview 改动
typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {
UIScrollViewContentInsetAdjustmentAutomatic, // Similar to .scrollableAxes, but for backward compatibility will also adjust the top & bottom contentInset when the scroll view is owned by a view controller with automaticallyAdjustsScrollViewInsets = YES inside a navigation controller, regardless of whether the scroll view is scrollable
UIScrollViewContentInsetAdjustmentScrollableAxes, // Edges for scrollable axes are adjusted (i.e., contentSize.width/height > frame.size.width/height or alwaysBounceHorizontal/Vertical = YES)
UIScrollViewContentInsetAdjustmentNever, // contentInset is not adjusted
UIScrollViewContentInsetAdjustmentAlways, // contentInset is always adjusted by the scroll view's safeAreaInsets
} API_AVAILABLE(ios(11.0),tvos(11.0));if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}//这样写 并不work
[self.filterListView scrollToRowAtIndexPath:self.selectedIndexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:NO];
// 加上0.1秒的延迟就好了 https://stackoverflow.com/questions/46075517/uitableview-scrolltorow-no-longer-works-on-ios-11-right-after-adding-a-new-row
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.filterListView scrollToRowAtIndexPath:self.selectedIndexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:NO];
});Last updated
