2013-03-16 28 views
1

動態設置自定義UITableViewCell高度。如果文本包含換行符,則計算的高度不正確。使用換行符自定義UITableViewCell高度

enter image description here

enter image description here

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{   
     CGSize constraintSize = {320.0, 20000}; 
     CGSize neededSize = [_beerDetails.notes sizeWithFont:[UIFont systemFontOfSize:10.0f] constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap]; 
     return neededSize.height + 50; 
} 

回答

0

如您在 'constraintSize' 寬度不小於320(因爲這是iPhone屏幕的全寬)?你也許可以嘗試寬度爲300或290.

+0

感謝您的回覆。我嘗試了'constraintSize'的一些值,而273的效果最好。 – 2013-03-16 04:46:07

相關問題