I'm using iOS9 XCode7 I need to change the height of cell Dynamically according to labelText Height
I have used:
self.tableView.rowHeight=UITableViewAutomaticDimension;
But it is not working for custom made cell.
sizetoFit
is removed in iOS9.
Please suggest something. Thanks
try this. it is so simple.
set this height in heightForRowAtIndexPath method
then
Give your label constrains relative to the cell, top, bottom, left and right.
Than your cell size will grow with the content height.
also make your label multiline.(by setting Lines property to 0 in attribute inspector)
I'm not quite sure what this sentence means (a screenshot would've helped):
"I need to change the height of cell Dynamically according to labelText Height"
So, you have a
UITableViewCell
, containing aUILabel
, and want each cell in your table to have a height depending on that cell's label ?Here's the code I use.
In my
UITableViewCell
class, I'll define a static function to measure, and return the height of my .xib file:Then, in my
UIViewController
class, I'll tell myUITableView
to use this cell, find out it's height.Again, this might not be exactly what you're looking for, but I hope this helps.