ios iOS 11中collectionView布局混乱的问题

如果你的界面中含有collectionView,需要在viewDidLoad里加上下面这段代码,这样系统就会按咱们写的布局来布局控件啦,

if (@available(iOS 11.0, *)) {

        self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用

    }else {

        self.automaticallyAdjustsScrollViewInsets = NO;

    }



下面是iOS11 中UITableView组头高度问题解决办法,

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {

        return 10;

}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {

    return 0.1;

}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

    return [UIView new];

}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

{

    return [UIView new];

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容