masonry 레이아웃 을 사용 할 때 UITableViewCell 자체 적응 고도 도구

masonry 레이아웃 을 사용 할 때 UITableViewCell 자체 적응 고도 도구
HYBMasonryAutoCellHeight
github:https://github.com/CoderJackyHuang/HYBMasonryAutoCellHeight
관련 설명
Masonry 자동 줄 높이 계산:http://101.200.209.244/masonry-cell-height-auto-calculate/
관련 사용
  • 레이아웃 위치 추가UI UITableViewCell -initWithStyle:reuseIdentifier: hyb_lastViewInCell
  • UITableView Cell 에 Cell 의 맨 밑 에 있 는 컨트롤 을 설정 합 니 다.필요 하 다 면 맨 밑 에 있 는 컨트롤 이 cell 밑 에 있 는 높이 를 설정 할 수 있 습 니 다.다음 과 같 습 니 다.
  • /**
     *        ,    cell  contentView       ,      
     *   ,       button   cell         ,    :self.hyb_lastVieInCell = button;
     *   。
     *    nil,      ,  nil, crash
     */
    @property (nonatomic, strong) UIView *hyb_lastViewInCell;
    
    /**
     *        ,   0,     hyb_lastViewInCell cell bottom   
     *    0.0
     */
    @property (nonatomic, assign) CGFloat hyb_bottomOffsetToCell;
    
  • UITableView Delegate 에서 호출
  • /**
     *           ,   config        API
     *
     * @param indexPath   ,   indexPath
     * @param confi          ,          API
     *
     * @return      
     */
    + (CGFloat)hyb_heightForIndexPath:(NSIndexPath *)indexPath config:(HYBCellBlock)config;
    
          
    - (CGFloat)tableView:(nonnull UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
      HYBNewsModel *model = nil;
      if (indexPath.row < self.dataSource.count) {
        model = [self.dataSource objectAtIndex:indexPath.row];
      }
    
      return [HYBNewsCell hyb_heightForIndexPath:indexPath config:^(UITableViewCell *sourceCell) {
        HYBNewsCell *cell = (HYBNewsCell *)sourceCell;
        
        //     
        [cell configCellWithModel:model];
      }];
    }
    

    좋은 웹페이지 즐겨찾기