Xcode9的坑

在此记录一下,方便日后复制剪贴,节省时间

1.某些使用tableView或ScrollView界面下沉64dpt,原因是 automaticallyAdjustsScrollViewInsets 在iOS11被废弃

解决:

    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }

automaticallyAdjustsScrollViewInsets设置为NO,tableView的frame适配

  CGFloat navHeight = CGRectGetMaxY(self.navigationController.navigationBar.frame);
        CGRect tabFrame = CGRectMake(0, navHeight, SCREEN_WIDTH, SCREEN_HEIGHT-navHeight);

2.cell的顶部或者底部多出一片空白区域

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.001;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.001;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [UIView new];
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [UIView new];
}

你可能感兴趣的:(Xcode9的坑)