iOS11 以来,需要全局适配一些UI ,记录一下吧。写了一个全局的适配方式,在 AppDelegate 调用一次就行了。
- (void)configScrollViewInIos11 {
if (@available(iOS 11.0, *)) {
[UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[UITableView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[UITableView appearance].estimatedRowHeight = 0;
[UITableView appearance].estimatedSectionHeaderHeight = 0;
[UITableView alloc].estimatedSectionFooterHeight = 0;
[UICollectionView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[UIWebView appearance].scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[WKWebView appearance].scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
}
大致就是处理一些容器视图,web视图 在ios11 下,导航栏偏移的问题。
还有就是使用 WKWebView 注意,自己测试发现在 iOS9 下,如果页面释放的时候,没有将 WKWebView相关代理置空,会导致返回页面崩溃问题。处理如下
- (void)dealloc {
[_wkWebView removeFromSuperview];
_wkWebView.scrollView.delegate = nil;
_wkWebView.navigationDelegate = nil;
_wkWebView = nil;
}