Domanda

I want to calculate the cell height using code. My text contains html entities like <br>,<b> etc. I tried the following or similar code -

//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;

it works fine for single line code and plain text but having issues with text containing html tags.

Please help.

È stato utile?

Soluzione

Try this tutorial related to Cell Height, ang try some googling for this http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top