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;
}];
}
TableView cell自适应高度-----xib的更多相关文章
- 自定义cell自适应高度
UITableView在许多App种被大量的应用着,呈现出现的效果也是多种多样的,不能局限于系统的一种样式,所以需要自定义cell 自定义cell呈现的内容也是多种多样的,内容有多有少,所以需要一种能 ...
- Cell自适应高度及自定义cell混合使…
第一部分:UItableViewCellAdaptionForHeight : cell的自适应高度 第二部分:CustomTableViewCell:自定义cell的混合使用(以简单通讯录为例) = ...
- cell自适应高度
MyModel.h #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface MyModel : ...
- 自定义 cell 自适应高度
#import "CommodityCell.h" #import "UIImageView+WebCache.h" @implementation Commo ...
- IOS XIB Cell自适应高度实现
1.代码实现Cell高度自适应的方法 通过代码来实现,需要计算每个控件的高度,之后获取一个cell的 总高度,比较常见的是通过lable的文本计算需要的高度. CGSize labelsize = [ ...
- 自定义cell 自适应高度
#pragma mark - 动态计算cell高度 //计算 返回 文本高度 + (CGFloat)calsLabelHeightWithContact:(Contacts *)contact { / ...
- iOS之UITableView加载网络图片cell自适应高度
#pragma mark- UITableView - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSI ...
- iOS UItableview 镶嵌 collectionView ,cell 自适应高度动态布局
最近在写这个功能,之前看到很多,可是需求一直没有涉及到,大致思路是有的,发现,网上的大部分都有缺陷和bug,我也是好无语啦啦啦,也不晓得是不是升级 了xcode,一样的代码,允许的效果都不一样,,,苦 ...
- swift学习 - tableView自适应高度1(xib autoLayout)
tableView自适应高度 效果图: 源码: class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSo ...
随机推荐
- C#Redis 主从复制
一.前戏 下面的列表清楚的解释了Redis Replication的特点和优势. 1). 同一个Master可以同步多个Slaves. 2). Slave同样可以接受其它Slaves的连接 ...
- linux 下maven安装
版本要求maven3.2.3 软件下载 wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.2.3/binaries/apache-maven-3 ...
- Struts2框架(5)---result结果集
result结果集 上一篇文章主要讲Struts2框架(4)---Action类访问servlet这篇主要讲result结果集 在Struts.xml中的result元素指的是:指定动作类的动作方法执 ...
- Redis 安装与简单使用
安装 Redis 一般系统都会有软件管理工具,但是通常版本都不会太新,况且 Redis 的安装很简单,因此下面使用源码的安装方式. 下载源码 wget http://download.redis.io ...
- 算法模板——sap网络最大流 2(非递归+邻接表)
实现功能:同最大流 1 这里面主要是把前面的邻接矩阵改成了邻接表,相比之下速度大大提高——本人实测,当M=1000000 N=10000 时,暂且不考虑邻接矩阵会不会MLE,新的程序速度快了很多倍(我 ...
- Oracle-orclEXORIM
imp pzhdb/hiway@orcl file =d:\pzhsd.dmp fromuser = pzhsd touser=pzhdb:导入 第一个pzhdb为新的用户名 hiway为密码 orc ...
- velocity中使用枚举
版权声明:本文为博主原创文章,转载请注明出处,欢迎使劲喷 一.为什么要在velocity中使用枚举 1.目前接触到的系统,枚举通常用来在程序中定义数据字典. 举个支付的例子,比如一个字段用来标识一条记 ...
- redux三个基本原则
(1)单一数据源:整个应用的state被存储在一棵object tree中,并且这个object tree只存在于唯一一个store中: (2)state是只读的:唯一改变state的方法就是触发ac ...
- spring切面编程AOP 范例一
参照网上的spring AOP编程实例进行配置,但是碰到了几个坑.这篇文章重点讲解一下我踩过的两个坑: 1.使用@Service自动装配的时候,基础扫描包配置要正确: 2.xml中切面配置中的exec ...
- idea调试SpringMvc, 出现:”通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明“错误的解决方法
调试json格式输出,出现以下错误: HTTP Status 500 - Servlet.init() for servlet HelloDispatcher threw exception ty ...