您好,我正在努力确定此应用程序使用哪种对象来填充下面的字段,它会根据文本量自动调整大小,并且每个字段都没有滚动,只有所有在一起。我已经尝试过标签、 TextView ,但没有用。
开发人员回复,他使用“CUSTOM UIVIEW”,知道怎么做吗?谢谢
最佳答案
我最好的猜测是他们正在使用 UITableView
并根据每行中的文本即时计算 UITableViewCell
高度。
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
// Calculate the height of the row, based on the string for this indexPath
}
在 iOS 7 上,您可以使用以下 NSString
方法来确定给定矩形中字符串的高度:
- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(NSDictionary *)attributes context:(NSStringDrawingContext *)context;
在 iOS 6 及更早版本上,您可以使用:
- (CGSize)sizeWithFont:(UIFont *)font forWidth:(CGFloat)width lineBreakMode:(NSLineBreakMode)lineBreakMode;
关于ios - 谁能识别这个对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22813182/