Study TableView How to calculate dynamic row height study for two days has not been very likely, today finally made out the desired effect.
First of all, I collected a lot of information on the Internet, the summary of various great gods, and then began to look at, research, testing, the basic ideas are the same.
1. Be sure to set the label's numberofline to 0
2. Size required for text message
3. set the height of the label to Titlesize.height
4. In- (CGFloat) TableView: (UITableView*) TableView Heightforrowatindexpath: (Nsindexpath*) in Indexpath
Return cell initial height plus label increased height.
In the end I used the method is friend told, the idea is the same.
The method used to fetch the label height is
<pre name= "code" class= "OBJC" >[str boundingrectwithsize:size options:nsstringdrawinguseslinefragmentorigin Attributes:@{nsfontattributename:font} context:nil].size
This is a good thing to do. I'm wrapping it up as a method, put it in the category of NSString, and return a desired result as needed to pass in the parameter.
Just write it down.
The article references a lot, write down a few better blog address, perhaps also can use
Dong Platinum Http://www.cnblogs.com/dsxniubility/p/4590474.html
Pengyingh http://www.cnblogs.com/pengyingh/articles/2347700.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Summary of TableView calculation of dynamic row height