熬夜看了一下發(fā)布會(huì),唉按声,又要適配了膳犹,但iOS最起碼比Android那邊適配還是輕松點(diǎn)。運(yùn)行iPhoneX模擬器签则,發(fā)現(xiàn)原先在7p上完好的適配竟然有問題须床。
tableview這一塊的空白是什么原因?
渐裂,但是在其它設(shè)備上確實(shí)沒有這個(gè)問題啊豺旬。包括下面的tableBar也有點(diǎn)不適應(yīng)。好吧柒凉,我首先想到是不是應(yīng)該
self.automaticallyAdjustsScrollViewInsets = NO;
族阅,檢查一下代碼(反正也是別人的項(xiàng)目,得從頭開始查看
),沒有問題膝捞。難道是自動(dòng)打開了Self-Sizing
的原因坦刀?但是這里純手寫代碼,并沒有用xib啊,管他的鲤遥,先關(guān)閉再說沐寺,在iOS 11中Table Views默認(rèn)啟用Self-Sizing的,Headers, footers, and cells都默認(rèn)開啟Self-Sizing盖奈,
混坞,我就在代碼中添加了關(guān)閉的代碼:
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
運(yùn)行一下,然并卯案痔埂0蔚凇!场钉!蚊俺,我表示很無奈,沒辦法逛万,開始查閱資料泳猬。我靠!
@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets API_DEPRECATED_WITH_REPLACEMENT("Use UIScrollView's contentInsetAdjustmentBehavior instead", ios(7.0,11.0),tvos(7.0,11.0)); // Defaults to YES
iOS11棄用了automaticallyAdjustsScrollViewInsets屬性宇植,新增contentInsetAdjustmentBehavior來替代它得封。
contentInsetAdjustmentBehavior
/* Configure the behavior of adjustedContentInset.
Default is UIScrollViewContentInsetAdjustmentAutomatic.
*/
@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior API_AVAILABLE(ios(11.0),tvos(11.0));
typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {
UIScrollViewContentInsetAdjustmentAutomatic,
// 和scrollableAxes一樣,scrollView會(huì)自動(dòng)計(jì)算和適應(yīng)頂部和底部的內(nèi)邊距并且在scrollView 不可滾動(dòng)時(shí),也會(huì)設(shè)置內(nèi)邊距.
UIScrollViewContentInsetAdjustmentScrollableAxes,
//自動(dòng)計(jì)算內(nèi)邊距.
UIScrollViewContentInsetAdjustmentNever,
// 不計(jì)算內(nèi)邊距
UIScrollViewContentInsetAdjustmentAlways,
// 根據(jù)safeAreaInsets 計(jì)算內(nèi)邊距
呦呦切克鬧,開始適配指郁,只需要判斷一下
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
_tableView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0);
_tableView.scrollIndicatorInsets = _tableView.contentInset;
}
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
tableView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0)
tableView.scrollIndicatorInsets = tableView.contentInset
}
在聲明tableView地方添加就可以解決了
如果出現(xiàn)沒有全屏的情況下忙上,應(yīng)該是你的launchImages的原因,讓美工出一個(gè)@3倍圖
修改好了