zoukankan      html  css  js  c++  java
  • iOS UITableViewCell中包含UICollectionView嵌套 解决UITableViewCell显示异常

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        LRPatientCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    //下面两句是关键
        cell.frame = tableView.bounds;
        [cell layoutIfNeeded];
        cell.item = self.array[indexPath.row];
        return cell;
    }
    
    
    
    - (void)setItem:(LRPatientCommentItem *)item {
        _item = item;
        // 标签
        [self.collectionView reloadData];
      
        [self layoutSubviews];//这句是关键
    }
    
    //这里获取collectionView 显示高度进行更新
    - (void)layoutSubviews {
        [super layoutSubviews];
        CGFloat height = self.collectionView.collectionViewLayout.collectionViewContentSize.height;
        [self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(height);
        }];
        NSLog(@"height  %f",height);
    }

    参考

    https://blog.csdn.net/zhanglizhi111/article/details/86292634

  • 相关阅读:
    JavaScript入门二
    JavaScript入门
    CSS样式之补充
    CSS样式之操作属性二
    隔空手势操作
    项目管理培训(2)
    uoot启动过程
    new work
    库函数开发步骤 (转)
    keil(持续更新)
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14633383.html
Copyright © 2011-2022 走看看