iOS11適配 tableView頂部多一塊 cell高度錯誤

之前的estimatedSection******Height默認爲0,現在不爲0了,直接寫第一部分代碼也可以,或者不設置estimatedSection,把代碼2兩個代理補上也行,看自己選擇,本質原因就是因爲默認值問題,這兩種方式都可以解決這個默認值問題

代碼1

if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        // est和代理 可選1self.tableView.estimatedSectionFooterHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }

代碼2

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return nil;
}

cell高度出現高度重合問題

self.tableView.estimatedRowHeight = 0;

default is UITableViewAutomaticDimension, set to 0 to disable

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章