2

コードを使用してセルの高さを計算したい。私のテキストには、などのhtmlエンティティが含まれています<br>,<b>。次のコードまたは同様のコードを試しました-

//create a CGFloat variable
CGFloat _height = 0;
//find out the size for your text. Instead of 255 insert the width of your label
CGSize _textSize = [yourString sizeWithFont:[UIFont systemFontOfSize:kFontSize] constrainedToSize:(CGSize) { 255, 9999 }];
//add the height of that CGSize variable to your height in case you will need to add more values
_height += _textSize.height;

1行のコードとプレーンテキストでは問題なく機能しますが、htmlタグを含むテキストには問題があります。

助けてください。

4

1 に答える 1

1

セルの高さに関連するこのチュートリアルを試してみてください。このhttp://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/をグーグルで試してみて ください。

于 2012-04-26T06:10:42.593 に答える