iOS 15 UITableView 分組高度顯示異常處理方案

在 iOS15 中UITableView新增了屬性有:

/// Determines if the table view allows its cells to become focused.
/// When tableView:canFocusRowAtIndexPath: is implemented, its return value takes precedence over this method.
/// Defaults to a system derived value based on platform and other properties of the table view.
@property (nonatomic, getter=isPrefetchingEnabled) BOOL prefetchingEnabled
/// The height for filler rows added below the last row when there aren't enough rows to fill a plain style table view.
/// Set 0 to disable filler rows entirely, use `UITableViewAutomaticDimension` for the default height.
@property (nonatomic) CGFloat fillerRowHeight
/// Padding above each section header. The default value is `UITableViewAutomaticDimension`.
@property (nonatomic) CGFloat sectionHeaderTopPadding
/// Determines if the table view allows its cells to become focused.
/// When tableView:canFocusRowAtIndexPath: is implemented, its return value takes precedence over this method.
/// Defaults to a system derived value based on platform and other properties of the table view.
@property (nonatomic) BOOL allowsFocus
/// Determines if the table view allows its cells to become focused while editing.
/// When tableView:canFocusRowAtIndexPath: is implemented, its return value takes precedence over this method.
/// Defaults to a system derived value based on platform and other properties of the table view.
@property (nonatomic) BOOL allowsFocusDuringEditing

方法:

// Reconfigures any existing cells for the rows. Reconfiguring is more efficient than reloading a row, as it does not replace the
// existing cell with a new cell. Prefer reconfiguring over reloading unless you actually need an entirely new cell for the row.
- (void)reconfigureRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths 
/// Determines if the row at the specified index path should also become selected when focus moves to it.
/// If the table view's global selectionFollowsFocus is enabled but this delegate returns NO, focus will still move to the cell upon selection, but the cell will no longer become selected when focus moves to it.
- (BOOL)tableView:(UITableView *)tableView selectionFollowsFocusForRowAtIndexPath:(NSIndexPath *)indexPath

其中屬性值sectionHeaderTopPadding, 設(shè)sectionHeaderTopPadding為 0即可块蚌。

  • 部分頁面設(shè)置
if (@available(iOS 15.0, *)) {
    _tableView.sectionHeaderTopPadding = 0;
}
  • 全局設(shè)置
if (@available(iOS 15.0, *)) {
    [UITableView appearance].sectionHeaderTopPadding = 0;
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末轩性,一起剝皮案震驚了整個濱河市步绸,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌势篡,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,252評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異洒敏,居然都是意外死亡咏花,警方通過查閱死者的電腦和手機(jī)趴生,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評論 3 399
  • 文/潘曉璐 我一進(jìn)店門阀趴,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人苍匆,你說我怎么就攤上這事刘急。” “怎么了浸踩?”我有些...
    開封第一講書人閱讀 168,814評論 0 361
  • 文/不壞的土叔 我叫張陵叔汁,是天一觀的道長。 經(jīng)常有香客問我检碗,道長据块,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,869評論 1 299
  • 正文 為了忘掉前任折剃,我火速辦了婚禮另假,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘微驶。我一直安慰自己浪谴,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,888評論 6 398
  • 文/花漫 我一把揭開白布因苹。 她就那樣靜靜地躺著苟耻,像睡著了一般。 火紅的嫁衣襯著肌膚如雪扶檐。 梳的紋絲不亂的頭發(fā)上凶杖,一...
    開封第一講書人閱讀 52,475評論 1 312
  • 那天,我揣著相機(jī)與錄音款筑,去河邊找鬼智蝠。 笑死,一個胖子當(dāng)著我的面吹牛奈梳,可吹牛的內(nèi)容都是我干的杈湾。 我是一名探鬼主播,決...
    沈念sama閱讀 41,010評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼攘须,長吁一口氣:“原來是場噩夢啊……” “哼漆撞!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起于宙,我...
    開封第一講書人閱讀 39,924評論 0 277
  • 序言:老撾萬榮一對情侶失蹤浮驳,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后捞魁,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體至会,經(jīng)...
    沈念sama閱讀 46,469評論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,552評論 3 342
  • 正文 我和宋清朗相戀三年谱俭,在試婚紗的時候發(fā)現(xiàn)自己被綠了奉件。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片宵蛀。...
    茶點(diǎn)故事閱讀 40,680評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖瓶蚂,靈堂內(nèi)的尸體忽然破棺而出糖埋,到底是詐尸還是另有隱情,我是刑警寧澤窃这,帶...
    沈念sama閱讀 36,362評論 5 351
  • 正文 年R本政府宣布瞳别,位于F島的核電站,受9級特大地震影響杭攻,放射性物質(zhì)發(fā)生泄漏祟敛。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,037評論 3 335
  • 文/蒙蒙 一兆解、第九天 我趴在偏房一處隱蔽的房頂上張望馆铁。 院中可真熱鬧,春花似錦锅睛、人聲如沸埠巨。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽辣垒。三九已至,卻和暖如春印蔬,著一層夾襖步出監(jiān)牢的瞬間勋桶,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評論 1 274
  • 我被黑心中介騙來泰國打工侥猬, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留例驹,地道東北人。 一個月前我還...
    沈念sama閱讀 49,099評論 3 378
  • 正文 我出身青樓退唠,卻偏偏與公主長得像鹃锈,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子瞧预,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,691評論 2 361

推薦閱讀更多精彩內(nèi)容