I cannot seem to replace the deprecated sizeWithFont
with boundingRecWithSize
correctly. I scoured through all the answers and stayed up all night trying to fix this.I really need help from someone way smarter than I. Here is the code I am trying to modify. Any help would be appreciated.
CGSize sizeForText = [faqItem.answer sizeWithFont:[UIFont boldSystemFontOfSize:14]
constrainedToSize:CGSizeMake(self.tblView.bounds.size.width - padding, MAXFLOAT)
lineBreakMode:NSLineBreakByWordWrapping];
[sectionInfo insertObject:[NSNumber numberWithFloat:roundf(sizeForText.height + 5)]
inRowHeightsAtIndex:0];
You need to use the sizeWithAttributes property.
You can also set it to an already created font size in order to reduce recoding if you use the size more than once:
I do not believe you can use constrainedToSize with this property. It would have to be separately set on a CGRect.
In apple documentation:
So you can use sizeWithAttributes: like this:
I wrote an sample for you, hope it's helpful.