don*_*ile 1 iphone uitableview
我需要在表格视图中提供一些信息,其中一些信息非常平坦,而另一些信息非常大.即一个信息实际上只是一行文本,而另一个是三行文本.
据我所知,UITableView要求所有单元格的高度.那么有没有办法让细胞具有不同的高度?
是的,请参阅:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
示例实现:
NSString *string...;
CGFloat CellWidth...;
CGSize size = [string sizeWithFont:[UIFont systemFontOfSize:14.0]
constrainedToSize:CGSizeMake(textWidth, MAXFLOAT)
lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = size.height;
if (height + 13.0) < 44.0) {
return 44.0;
}
return height + 13.0;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
147 次 |
| 最近记录: |