Xcode13&iOS 15适配之TableView

2,275 阅读1分钟
  • sectionHeaderTopPadding 自iOS 15以来,UITableView有了一个sectionheadertoppadding的新属性,它指定每个Section Header上面的间隙Gap。
if ( @available(iOS 15.0, *)) {
    _mainTable.sectionHeaderTopPadding = 0;
} else {
    // Fallback on earlier versions
}
  • alloc 之后 init 之前 调用某些方法会崩溃,比如:
CGFloat top = 88;
self.contentInset = UIEdgeInsetsMake(self.contentInset.top, self.contentInset.left, top, self.contentInset.right);
  • 解决办法就是改到 init方法里
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
    self = [super initWithFrame:frame style:style];
    self.contentInset = .....等方法
    return self;
}