問題一
- 描述
- 當列表有多余一頁的數(shù)據(jù),上拉加載數(shù)據(jù)且
reloadData
完成后,tableView的contentOffset發(fā)生了不必要的變化,導致列表會向上拉動一段位移,觀察發(fā)現(xiàn),reloadData
之后,tableView
的contentOffset
發(fā)生了幾次變化。 -
如圖
image.png
- 當列表有多余一頁的數(shù)據(jù),上拉加載數(shù)據(jù)且
- 原因
Google了一下,發(fā)現(xiàn)原因是 iOS11 中默認開啟了Self-Sizing
,即Headers
,Footers
, andCells
都默認開啟Self-Sizing
,所有estimated
高度默認值從iOS11之前的0.0
改變?yōu)?code>UITableViewAutomaticDimension。我們的項目雖然沒有使用estimateRowHeight
屬性,在iOS11
的環(huán)境下默認開啟Self-Sizing
之后,這樣就會造成contentSize
和contentOffset
值發(fā)生不可預知的變化,如果是有動畫是觀察這兩個屬性的變化進行的,就會造成動畫的異常,因為在估算行高機制下,contentSize
的值是一點點地變化更新的,所有cell
顯示完后才是最終的contentSize
值,因為不會緩存正確的行高,reloadData
的時候,會重新計算contentSize
,就有可能會引起contentOffset
的變化
@property (nonatomic) CGFloat estimatedRowHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
- 解決方案
通過關閉Self-Sizing
,可以解決上述問題
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
問題二
- 描述
- 報名榜樣房UI錯亂
-
如圖
image.png
- 原因
iOS11對導航欄有較大改動,現(xiàn)在rightBarButtonItem
是不能獲取到相對于導航欄的坐標了
_lineImageView.left = frame.origin.x + frame.size.width / 2.0;
- 解決方案
因沒有找到合適獲取坐標的方案,所以給定了左邊距離邊框的寬度
_lineImageView.left = yScreenWidth - (18.0 + frame.size.width / 2.0);
問題三
- 描述
- 各種主頁下拉箭頭露了出來
-
如圖
image.png - 解決方案
if (kSystemVersion >= 11.0 && [self.managerOwner isKindOfClass:[UIScrollView class]]) {
UIScrollView *tempScrollView = (UIScrollView *)self.managerOwner;
if (@available(iOS 11.0, *)) {
tempScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
}
問題四
- 描述
- TabBar發(fā)布按鈕點擊,奔潰!
- 日志如下
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<UIView: 0x127dcd820; frame = (0 0; 320 568); layer = <CALayer: 0x1c0239600>> has been added as a subview to <UIVisualEffectView: 0x127dcbda0; frame = (0 0; 320 568); layer = <CALayer: 0x1c022fd00>>. Do not add subviews directly to the visual effect view itself, instead add them to the -contentView.'
- 原因
查看UIVisualEffectView
發(fā)現(xiàn)了不能在它上面直接添加子視圖,需要添加在它的contentView上
@property (nonatomic, strong, readonly) UIView *contentView; // Do not add subviews directly to UIVisualEffectView, use this view instead.
- 解決方案
//[self.bgView addSubview:self.contentView];
[self.bgView.contentView addSubview:self.contentView];
上面的bgView是UIVisualEffectView