#import <UIKit/UIKit.h>

@interface TestCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *testLabel;
- (void)parseResult:(NSString *)result;
@end
#import "TestCell.h" @implementation TestCell - (void)awakeFromNib { }
- (void)parseResult:(NSString *)result
{
_testLabel.text= result;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated]; // Configure the view for the selected state
} @end
#import "ViewController.h"
#import "TestCell.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
{ NSArray *dataArray;
}
@property (weak, nonatomic) IBOutlet UITableView *testTableView;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
dataArray = @[@"1234\n56789012\n34567\n]\n890\n12341\n2\n3\n4\n5\n6", @"12345\n67890\n1234\n56789\n01234\n567890", @"1\n2", @"1\n2\n3", @"1\n"]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return ;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TestCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TestCell" forIndexPath:indexPath];
[cell parseResult:dataArray[indexPath.row]];
return cell; }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
TestCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TestCell"];
[cell parseResult:dataArray[indexPath.row]];
CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
NSLog(@"第%ld行的高度=%f",indexPath.row ,size.height + );
return + size.height; } @end

ios uitableviewcell动态计算高度的更多相关文章

  1. 键盘弹起及lab时的动态计算高度 --董鑫

    1.键盘抬起或掉下时,动态计算高度 2.动态计算Label的高度 计算的高度时,numberOfLines必须设置为0: 2.1  ios7.0之后 2.2 iOS 7.0之前

  2. iOS可视化动态绘制连通图

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  3. iOS应用动态部署方案

    iOS的动态部署能极大的节约成本.苹果的审核周期很长,有的时候,你可能不得不等待将近2个星期去上架你的新功能或者bug.所以动态部署是有价值的. 我这里讨论的情况不把纯web应用考虑在内,因为用户体验 ...

  4. WWDC2014之iOS使用动态库 framework【转】

    from:http://www.cocoachina.com/industry/20140613/8810.html JUN 12TH, 2014 苹果的开放态度 WWDC2014上发布的Xcode6 ...

  5. iOS本地动态验证码生成-b

    用于ios本地动态生成验证码,效果如下: demo.gif 导入CoreGraphics.framework用于绘制图形 封装UIView,便捷使用,代码如下: AuthcodeView.h #imp ...

  6. WWDC2014之iOS使用动态库

    苹果的开放态度 WWDC2014上发布的Xcode6 beta版有了不少更新,其中令我惊讶的一个是苹果在iOS上开放了动态库,在Xcode6 Beta版的更新文档中是这样描述的: Frameworks ...

  7. iOS可视化动态绘制连通图(Swift版)

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  8. iOS 使用动态库

    苹果的开放态度 WWDC2014上发布的Xcode6 beta版有了不少更新,其中令我惊讶的一个是苹果在iOS上开放了动态库,在Xcode6 Beta版的更新文档中是这样描述的: Frameworks ...

  9. IOS runtime动态运行时二

    在C#.Java中有编译时多态和运行时多态,在OC中,只有运行时的多态,这与它的运行机制有关.OC中,方法的调用是通过消息的传递来进行的.在IOS runtime动态运行时一http://www.cn ...

随机推荐

  1. Flex布局如何让子类在超出边界时隐藏掉

    在flex4中,因为必须添加<s:Scroller>标签才能出现滚动条,如果一个容器例如Panel没有添加滚动条,那么添加到Panel中的child的位置如果超出了Panel的边界,那么这 ...

  2. Unity3D Keynote

    [Unity3D Keynote] 1.场景文件扩展名为.unity. 2.up为Y正方向,down为Y负方向,right为X正方向,left为X负方向,forward为Z正方向,back为z负方向. ...

  3. POJ-2785 4 Values whose Sum is 0(折半枚举 sort + 二分)

    题目链接:http://poj.org/problem?id=2785 题意是给你4个数列.要从每个数列中各取一个数,使得四个数的sum为0,求出这样的组合的情况个数. 其中一个数列有多个相同的数字时 ...

  4. My集合框架第二弹 二叉树的实现

    package com.wpr.collection; import java.util.NoSuchElementException; public class BinarySearchTree&l ...

  5. oracle 学习笔记--用户管理

    oracle 用户管理 创建用户(需要具有dba权限的用户) create user 用户名 identified by 密码 defaule tablespace users     //默认表空间 ...

  6. c# abstract抽象类与继承类子类的构造函数_base

    http://blog.itpub.net/9240380/viewspace-718054/ http://blog.163.com/cloud_thegreat/blog/static/10367 ...

  7. Gartner:Hype Cycle for Emerging Technologies-2013

      The “Hype Cycle for Emerging Technologies” report is the longest-running annual Hype Cycle, provid ...

  8. SQL Server 批量插入数据的两种方法(转)

    此文原创自CSDN TJVictor专栏:http://blog.csdn.net/tjvictor/archive/2009/07/18/4360030.aspx 在SQL Server 中插入一条 ...

  9. Tomcat创建虚拟目录和程序热部署

    虚拟目录的设置 方法一:在${tomcat安装目录}/conf/Catalina/localhost目录下添加与web应用同名的xml配置文件,这里站点名称为test为例子. test.xml内容:& ...

  10. Emit Mapper官方文档

    概述 优点 快速指导 类型转换 用户配置