有时我们使用tableviewcell展示数据时,接受到的数据会超出我们初始化时设定的cell高度,这时我们就需要自适应cell的高度了.下面是返回cell高度的代码
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
luckNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 40, kScreenWidth - 90, 40)];
NSString *str = [[dataArray[indexPath.row] objectForKey:@"numbers"] componentsJoinedByString:@","];
luckNumberLabel.text = [NSString stringWithFormat:@"您的幸运号: %@",str];
luckNumberLabel.font = FONT(13.0);
luckNumberLabel.lineBreakMode = NSLineBreakByCharWrapping;
luckNumberLabel.numberOfLines = 0;
//自适应高度
CGRect txtFrame = luckNumberLabel.frame;
luckNumberLabel.frame = CGRectMake(80, 55, kScreenWidth - 90, txtFrame.size.height = [luckNumberLabel.text boundingRectWithSize:CGSizeMake(txtFrame.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:luckNumberLabel.font,NSFontAttributeName, nil] context:nil].size.height);
luckNumberLabel.frame = CGRectMake(80, 40, kScreenWidth - 90, txtFrame.size.height);
return luckNumberLabel.maxY + 50;
}
教程:风险投资追 踪器的作用
ChainLink价格预测:突破关键阻力位13.98美元后,LINK目标指向15美元 - Brave New Coin
Photoshop设计以金人为主题的2018世界杯宣传海报
功能:币圈仓位是什么?币圈仓位管理技巧和方法有哪些?
英国认证的ALL4 Mining为BTC、DOGE、XRP及其他热门加密货币爱好者推出最佳免费云挖矿服务
分析:币圈换手率多少是最佳买入点和卖出点?与成交量的关系是什么?