最近在写这个功能,之前看到很多,可是需求一直没有涉及到,大致思路是有的,发现,网上的大部分都有缺陷和bug,我也是好无语啦啦啦,也不晓得是不是升级 了xcode,一样的代码,允许的效果都不一样,,,苦滋滋的,今天又写了一遍,如果有问题请大家指出来。贴上代码

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self creatUI];
}
return self;
} - (void)creatUI {
self.contentView.backgroundColor=[UIColor redColor];
[self.contentView addSubview:self.collection];
// [self.contentView setNeedsLayout];
// [self.contentView layoutIfNeeded];
[self.collection mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.left.right.equalTo(self.contentView);
make.height.equalTo(@(Scale())).priorityLow();
}];
} - (void)setDataArry:(NSArray *)dataArry{
_dataArry = dataArry;
[self.collection reloadData];
[self.collection mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.equalTo(@(self.collection.collectionViewLayout.collectionViewContentSize.height)).priorityLow(); }];
}

这是图片:

主要代码如下:

iOS UItableview 镶嵌 collectionView ,cell 自适应高度动态布局的更多相关文章

  1. 自定义cell自适应高度

    UITableView在许多App种被大量的应用着,呈现出现的效果也是多种多样的,不能局限于系统的一种样式,所以需要自定义cell 自定义cell呈现的内容也是多种多样的,内容有多有少,所以需要一种能 ...

  2. TableView cell自适应高度-----xib

    1.通过xib创建一个cell,将label进行上左下右,进行适配, self.automaticallyAdjustsScrollViewInsets = NO; self.edgesForExte ...

  3. Cell自适应高度及自定义cell混合使…

    第一部分:UItableViewCellAdaptionForHeight : cell的自适应高度 第二部分:CustomTableViewCell:自定义cell的混合使用(以简单通讯录为例) = ...

  4. cell自适应高度

    MyModel.h #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface MyModel : ...

  5. 自定义 cell 自适应高度

    #import "CommodityCell.h" #import "UIImageView+WebCache.h" @implementation Commo ...

  6. iOS之UITableView加载网络图片cell自适应高度

    #pragma mark- UITableView - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSI ...

  7. IOS XIB Cell自适应高度实现

    1.代码实现Cell高度自适应的方法 通过代码来实现,需要计算每个控件的高度,之后获取一个cell的 总高度,比较常见的是通过lable的文本计算需要的高度. CGSize labelsize = [ ...

  8. 自定义cell 自适应高度

    #pragma mark - 动态计算cell高度 //计算 返回 文本高度 + (CGFloat)calsLabelHeightWithContact:(Contacts *)contact { / ...

  9. iOS UITextView 根据输入text自适应高度

    转载自:http://www.cnblogs.com/tmf-4838/p/5380495.html #import "ViewController.h" @interface V ...

随机推荐

  1. 阿里面试实战题1----TreeSet,HashSet 区别

    TreeSet,HashSet 区别 TreeSet public class TreeSet<E> extends AbstractSet<E> implements Nav ...

  2. Use a Multiline Editor for String Properties 对字符串属性使用多行编辑器

    In this lesson, you will learn how to display a multiline editor for string properties. For this pur ...

  3. CAD编辑器哪个好用?如何使用CAD编辑器

    说起CAD图纸很多的朋友都很熟悉,因为CAD图纸在很多领域都有广泛的应用.那CAD图纸都是使用CAD编辑器制图软件来进行绘制的,图纸的格式都是为dxf格式或者是dwg格式的.对于才接触CAD的伙伴们来 ...

  4. centOS如何灵活管理服务进程

     1.将程序跑起来,且关闭会话时程序仍在运行. nohup node index.js & (头部加了nohup,表示在你退出帐户或关闭终端之后继续运行相应的进程;尾部的&表示在后台执 ...

  5. [转]JS将图片转为base64编码

    本文转自:https://blog.csdn.net/DeMonliuhui/article/details/79731359 1.根据img标签获取base64编码/** * * @param im ...

  6. [Go] Golang中的面向对象

    struct interface 就可以实现面向对象中的继承,封装,多态 继承的演示:Tsh类型继承People类型,并且使用People类型的方法 多态的演示Tsh类型实现了接口Student,实现 ...

  7. IDEA springboot配置

    基于springboot2.1.7 springboot项目创建 springboot热部署 springboot配置swagger2 springboot配置mybatis springboot配置 ...

  8. php程序内存优化之数组操作优化

    一.前言这篇文章其实是上篇文章的内存优化部分.博主的php程序在执行的时候,报错: Out of memory (allocated 364904448) (tried to allocate 262 ...

  9. python做中学(四)main函数的用法

    什么场景下会有main函数? 当该python脚本被作为模块(module)引入(import)时,其中的main()函数将不会被执行. main函数的作用? __name__ == '__main_ ...

  10. python3编码问题总结

    关于python3的编码类型,到底是怎么编码的,一直使我比较疑惑,在看了网上很多帖子之后,经过自己尝试与实验,将自己的总结写在下面,一是当做一次笔记,二是希望网友们能指正.仅供参考,欢迎指正,谢谢!! ...