使用此代碼
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
CGFloat width=[UIScreen mainScreen].bounds.size.width;
//width - rigth and left constraints 8
NSString* strText = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum";
NSDictionary *attributesDictionary = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:17] forKey: NSFontAttributeName];
CGRect frame = [strText boundingRectWithSize:CGSizeMake(width - 8 - 8, 3000) options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin attributes:attributesDictionary context:nil];
// 16 for bottom and top space
return frame.size.height + 16;
}
顯示在其中創建約束 – 2014-10-20 08:55:33
@GrzegorzKrukowski你可以在這裏看到https://github.com/iamabhiee/Github代碼 – Abhishek 2014-10-20 09:36:00