zoukankan      html  css  js  c++  java
  • TableView cell自适应高度-----xib

    1.通过xib创建一个cell,将label进行上左下右,进行适配,

    self.automaticallyAdjustsScrollViewInsets = NO;

    self.edgesForExtendedLayout = UIRectEdgeNone;//将原点移动到navigationBar下面去了

    tableView.estimatedRowHeight = 37.0;//估计cell的高度

    tableView.rowHeight = UITableViewAutomaticDimension;//行高自适应

    //选中cell的时候让cell自适应高度

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    {

        [tableView deselectRowAtIndexPath:indexPath animated:true];

        WLTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

        UILabel *label = [cell.contentView viewWithTag:1000];

        [tableView beginUpdates];//开始更新

        if (label.numberOfLines == 0) {

            label.numberOfLines = 1;

        }else{

            label.numberOfLines = 0;

        }

        [tableView endUpdates];//结束更新

    }

    //cell显示的时候做一个动画

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

    {

        CGFloat offSet = tableView.contentOffset.y;

        if (offSet <=0) {

            return;

        }

        CGRect oldRect = cell.frame;

        CGRect newRect = cell.frame;

        newRect.origin.y += 50;

        cell.frame = newRect;

        [UIView animateWithDuration:0.5 animations:^{

            cell.frame = oldRect;

        }];

    }

  • 相关阅读:
    洛谷 P1430 序列取数
    洛谷 P2042 维护数列
    洛谷 P3391 【模板】文艺平衡树(Splay)
    Permutation UVA
    treap板子(洛谷 P3369 【模板】普通平衡树(Treap/SBT))
    Jumping Jack CodeForces
    Increasing Sequence CodeForces
    Cunning Gena CodeForces
    Hie with the Pie POJ
    ACboy needs your help HDU
  • 原文地址:https://www.cnblogs.com/qitiandasheng/p/5496545.html
Copyright © 2011-2022 走看看