IOS中Cell高度的自适应(ios6、ios7)
2014-01-10 11:56
337 查看
一:IOS7 cell 高度自适应
-(float)getHeight:(NSString *)text
{
if (self.interfaceOrientation ==
UIDeviceOrientationPortrait || self.interfaceOrientation ==
UIDeviceOrientationPortraitUpsideDown)
{
//正
CGRect rect=[text
boundingRectWithSize:CGSizeMake(screen_w,
1000)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary
dictionaryWithObjectsAndKeys:[UIFont
systemFontOfSize:12],NSFontAttributeName,
nil]
context:nil];
float x=rect.size.height;
return x+20;
}
else
{
//反
CGRect rect=[text
boundingRectWithSize:CGSizeMake(screen_h,
1000)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary
dictionaryWithObjectsAndKeys:[UIFont
systemFontOfSize:12],NSFontAttributeName,
nil]
context:nil];
float x=rect.size.height;
return x+20;
}
}
二:ios6 cell的高度的自适应
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath
*)indexPath
{
CGSize size = [self.str
sizeWithFont:[UIFont
systemFontOfSize:14]
constrainedToSize:CGSizeMake(320,
10000)];
return size.height+20;
}
-(float)getHeight:(NSString *)text
{
if (self.interfaceOrientation ==
UIDeviceOrientationPortrait || self.interfaceOrientation ==
UIDeviceOrientationPortraitUpsideDown)
{
//正
CGRect rect=[text
boundingRectWithSize:CGSizeMake(screen_w,
1000)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary
dictionaryWithObjectsAndKeys:[UIFont
systemFontOfSize:12],NSFontAttributeName,
nil]
context:nil];
float x=rect.size.height;
return x+20;
}
else
{
//反
CGRect rect=[text
boundingRectWithSize:CGSizeMake(screen_h,
1000)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:[NSDictionary
dictionaryWithObjectsAndKeys:[UIFont
systemFontOfSize:12],NSFontAttributeName,
nil]
context:nil];
float x=rect.size.height;
return x+20;
}
}
二:ios6 cell的高度的自适应
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath
*)indexPath
{
CGSize size = [self.str
sizeWithFont:[UIFont
systemFontOfSize:14]
constrainedToSize:CGSizeMake(320,
10000)];
return size.height+20;
}
相关文章推荐
- 在iOS7中让表视图变成iOS6的圆角矩形与纯汉字文本的cell高度自适应
- iOS UITableViewCell自适应高度单元格问题?
- iOS UITableViewableViewCell自适应高度
- iOS cell高度自适应_动态调节cell高度
- iOS Cell高度自适应
- IOS TableView的Cell高度自适应,UILabel自动换行适应(转载)
- ios-cell多行文字高度自适应
- IOS Swift语言开发 tableView的重用以及自cell的自适应高度
- iOS学习笔记 自定义cell并且文本自适应高度
- 详解iOS tableViewCell自适应高度 第三发类库
- IOS研究成果——在autolayout 如何实现 Cell 的高度自适应
- iOS 中 cell和 label 的自适应高度
- iOS 客户端学习-UITableViewCell高度自适应
- IOS TableView的Cell高度自适应,UILabel自动换行适应
- iOS 给tableView 每行设置预估行高estimatedRowHeight,达到cell高度的自适应
- ios cell自适应高度
- ios TableView的Cell高度自适应,UILabel自动换行适应
- IOS TableView的Cell高度自适应,UILabel自动换行适应
- iOS7中Cell高度 Label高度自适应
- iOS开发之tableViewCell高度自适应