【发布时间】:2009-08-30 00:44:55
【问题描述】:
我正在尝试制作一个 UITableViewCell,它可以根据它显示的字符串的长度调整其高度,但我对这种方法感到困惑。
这是我得到的:
NSString *text = @"A really long string in here";
CGSize theSize = [text sizeWithFont:[UIFont boldSystemFontOfSize:18.0f] constrainedToSize:CGSizeMake(265.0f, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
NSString *stringHeight = [NSString stringWithFormat:@"%d", theSize.height];
无论如何,stringHeight 都会显示为0。我错过了什么?
谢谢!
【问题讨论】:
标签: iphone cocoa-touch nsstring