UITableViewCell的高度与UILabel自适应
UITableViewCell内部只放了一个UILabel,Cell的高度随着UILabel内容的高度变化而变化,可重写UITableView的委托方法动态调整高度,还要设置UILabel.numberOfLines = 0
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row == 1 {
//If it's content cell
var boundSize = CGSizeMake(300, 500)
var text = NSString(string: lblContent.text!)
let attributes = NSDictionary(object: UIFont(name: "Arial", size: 15)!, forKey: NSFontAttributeName)
let size = text.boundingRectWithSize(boundSize, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: attributes as [NSObject : AnyObject], context: nil)
return size.height + 10
} else {
return 44
}
}
UITableViewCell的高度与UILabel自适应的更多相关文章
- iOS-动态调整UITableViewCell的高度
OS-动态调整UITableViewCell的高度iOS开发文档, by 友盟翻译组 stefaliu. 大概你第一眼看来,动态调整高度是一件不容易的事情,而且打算解决它的第一个想法往往是不正确的.在 ...
- Textarea高度随内容自适应地增长,无滚动条
<HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; char ...
- textarea高度随内容自适应
最近遇到一个需求,视频名称初始有个生成值,并且支持可以手动修改,修改后名称过长后换行高度随内容增加.刚开始想到用input但是发现input不支持换行.后来用了textarea,用js来控制,下面是实 ...
- jQuery实现textarea高度根据内容自适应
//jQuery实现textarea高度根据内容自适应 $.fn.extend({ txtaAutoHeight: function () { return this.each(function () ...
- 【转】UITableViewCell自适应高度 UILabel自适应高度和自动换行
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { ...
- UILabel自适应高度,自动换行
CGRect rect; rect = self.labelInfo.frame; //UILabel高度自适应 rect.size.height = [self.labelInfo.text bou ...
- UILabel自适应高度
在网上看了一些,发现很多关于自适应高度的,不能用,就在下面写一种我常用的吧!保证可以直接粘贴复制到Xcode中运行. UILabel *label = [[UILabel alloc] init]; ...
- UILabel 自适应高度,宽度
mLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, 10, 1)]; mLabel1.text = @"my label 1, ...
- iOS之UILabel自适应高度、宽度
下列两条自适应高度和宽度的自定义方法:
随机推荐
- MySQL会创建临时表的几种情况
1.UNION查询: 2.用到TEMPTABLE算法或者是UNION查询中的视图: 3.ORDER BY和GROUP BY的子句不一样时: 4.表连接中,ORDER BY的列不是驱动表中的:(指定了联 ...
- go 语言字典元素删除
package main import "fmt" func main() { /* 创建map */ countryCapitalMap := map[string]string ...
- wireshark 下载
https://www.wireshark.org/download/win64/
- Could not find a package configuration file provided by 'ecl_geometry' ,.................couldn't find required component 'ecl_geometry'
sudo apt-get install ros-kinetic-ecl-geometry
- MongoDB(课时3 MongoDB基本操作)
3.3 MongoDB的基本操作 在MongoDB数据库里面存在数据库的概念,但没有模式(所有的信息都是按照文档保存的),保存数据的结构是BSON结构,只不过在进行一些数据处理的时候才会使用到Mong ...
- ESXi6.7安装流程和bug处理
·前言 ·准备工作 ·安装 ·Initializing IOV卡住 ·缺少网卡驱动 ·安装ESXi6.7 ·Multiboot could not setup the video subsystem ...
- Android 使用SQLite
SQLite简介 Google为Andriod的较大的数据处理提供了SQLite,他在数据存储.管理.维护等各方面都相当出色,功能也非常的强大.SQLite具备下列特点: 1.轻量级 使用 SQLit ...
- English trip V1 - 4.Do you have it? Teacher:Patrick Key: have - has doesn't have
In this lesson you will learn to describe what you have. STARTER Do you have a ...? # 你有...吗? car b ...
- 【异常】redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'PSETEX'
在spring中 针对 RedisTemplate类: private RedisTemplate<String, String> template; 当调用下面方法 template.o ...
- 20170728xlVba SSC_TODAY
Public Sub SSC_TODAY() Dim strText As String Dim Reg As Object, Mh As Object, OneMh As Object Dim i ...