iOS11适配tableview

来源:互联网 发布:骚男辣条淘宝店网址 编辑:程序博客网 时间:2024/06/12 10:35

1 tableview出现的问题,可以改所有的tableview继承于一个自定义的tableview,在里面适配iOS11.


@interface GWParentTableView : UITableView@end

@implementation GWParentTableView/*// Only override drawRect: if you perform custom drawing.// An empty implementation adversely affects performance during animation.- (void)drawRect:(CGRect)rect {    // Drawing code}*/- (id)initWithFrame:(CGRect)frame{    if (self = [super initWithFrame:frame]) {         [self adapt];    }    return self;}- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{    if (self = [super initWithFrame:frame style:style]) {        [self adapt];    }    return self;}//适配- (void)adapt{    [self adaptRefresh];    [self adaptPageOffset];}//滚动条高度跳动、上下拉刷新问题- (void)adaptRefresh{    self.estimatedRowHeight = 0;    self.estimatedSectionHeaderHeight = 0;    self.estimatedSectionFooterHeight = 0;}//列表/页面偏移- (void)adaptPageOffset{    if (@available(iOS 11.0, *)){        self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;    }}@end

2 scrollview,tabelview都会出现页面偏移问题,可以在appdelegate里面统计设置。


- (void)adaptPageOffset{    if (@available(iOS 11.0, *)){        self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;    }}



原创粉丝点击