7

に除外パスを持つ TextView がある場合UITableViewCell、特定の文字列のセルの高さを計算するにはどうすればよいですか?

4

2 に答える 2

4

textContainer実際には、とで遊ぶ必要はありませんlayoutManager。これは私にとってはうまくいきます。

UIBezierPath *exclusionPath = [UIBezierPath bezierPathWithRect:imageViewFrame];

UITextView *tempTextView = [[UITextView alloc] init];
[tempTextView setFont:font];
tempTextView.textContainer.exclusionPaths = @[exclusionPath];
[tempTextView.textStorage replaceCharactersInRange:NSMakeRange(0, [tempTextView.text length]) withString:text];

CGRect textViewFrame = [tempTextView frame];
textViewFrame.size.height = [tempTextView sizeThatFits:CGSizeMake(290, FLT_MAX)].height;
return textViewFrame.size.height;
于 2014-05-14T06:47:17.397 に答える