【发布时间】:2011-05-25 06:55:46
【问题描述】:
我正在根据标签高度和标签高度根据文本动态设置 tableView 单元格高度。当我给出带空格的文本时,它工作正常(例如:这是 stackoverflow 的问题)。但是当我输入长度为两行且没有空格的文本时(例如 ThisisQuestionforstackoverflow)。它占用两行,文本从第二行开始并在末尾剪切。它占用第一行完整空间和第二行(ThisisQuestionfor.....)。
我正在使用方法
- +(float) calculateHeightOfTextFromWidth:(NSString*) text: (UIFont*)withFont: (float)width:(UILineBreakMode)lineBreakMode
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
在 cellForRowAtIndexPath 中
float productNameHeight = [DetailsViewController calculateHeightOfTextFromWidth:warObj1.productName :valueFont : valueWidth :UILineBreakModeWordWrap];
UILabel *productNameValue = [[UILabel alloc] initWithFrame:CGRectMake(xCoordinateStartLocatioForValue,yCoordinateStartLocation,valueWidth,productNameHeight)];
你能帮我一下吗。提前谢谢
【问题讨论】:
标签: iphone objective-c cocoa-touch uikit