美文网首页
ios iOS 11中collectionView布局混乱的问题

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

作者: 一时虚荣 | 来源:发表于2017-12-28 16:11 被阅读0次

如果你的界面中含有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];

}

相关文章

网友评论

      本文标题:ios iOS 11中collectionView布局混乱的问题

      本文链接:https://www.haomeiwen.com/subject/jejvgxtx.html