In the image. Comments has a textview that has text overflown to below 3 cells . Ideally that should not happen.
I have a tableview with custom cells as xib files and some custom cells are subviews. Please let me know how to add auto layout for this subviews or xib's.
I read many posts they suggested.below code. But it doesn't work.
In ViewDidLoad.
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 50;
Please suggest a solution. Thank you.
It will works, but you need to update the height everytime a new character is input, so in your cellForRow, add textview.delegate = self, and in the textViewDidChange, do tableView.beginUpdate() and tableView.endUpdate(), the cell height will update correctly
Related
How can I manage the height of the TableViewHeader based on the lines of an UILabel?
I followed this guide but I can't manage the header height dynamically.
In the guide it is fixed to a fixed size to which I tried to add the height of the label but it doesn't work.
I would prefer to use a tableview and not a scrollview as the data is populated dynamically.
I also tried to modify the constraints of the label dynamically, but when scroll the view of the label is stretched and not the image.
Add this in viewDidLoad:
self.tableView.sectionHeaderHeight = UITableViewAutomaticDimension;
self.tableView.estimatedSectionHeaderHeight = 25;
After that just give correct constrains for the headerView . That's it! No need to implement heightForHeaderInSection
UIImageView height width is set to fillparent. and using follwing code to auto resize table cell.
DiscountTableView.Source = new DiscountsTVS(discounts);
DiscountTableView.EstimatedRowHeight = 164;
DiscountTableView.RowHeight = UITableView.AutomaticDimension;
but i am getting following output
not sure what i am doing wrong.
You can check working example here i hope this is useful for you.Dynamic hieght of tableviewcell
If you used UITableView.AutomaticDimension ,you need to add constraints in the xib or in the code
I have a tableviewcell with two labels and the label's height will change depending on the content so tableviewcell height will automatically change.
now how can I make tableview cell height to autogrow ?
Please clarify me if the tableview cell height will autogrow if the label height changes ?
To make it tableview cell autogrow you have to keep in mind of the following two things in mind,
Right constraint(top, bottom, right & left) for the UI elements inside the tableview cell.
Usage of UITableViewAutomaticDimension & estimatedRowHeight property as follows,
tableView.estimatedRowHeight = 100 // A rough estimated height for your cell.
tableView.rowHeight = UITableViewAutomaticDimension
Refer the following tutorial for better indepth explanation on how to implement it.
http://matteomanferdini.com/the-correct-way-to-display-lists-in-ios-and-what-many-developers-do-wrong/#autolayout
https://www.youtube.com/watch?v=e1KJQs0frbM
I have a UITableView with cells that have inside a UICollectionView.
Now all works great except of UICollectionViewCell scrolling i want that the height of table view cell follow the Collection view cell content.
In simple word i want scrolling in table view but not inside single cell i need to display all contents of UIcollectionViewCell without scrolling inside it.
Thanks
You have to calculate the collectionviews' heights and set a height constraint on each of them. then add top and bottom constraints from the collectionviews to their superviews (the tableviewcells / their contentviews) and let autolayout do its work.
don't forget
tableView.estimatedRowHeight = 44 // or something similar
tableView.rowHeight = UITableViewAutomaticDimension
in the controller's viewDidLoad to make the automatic row height calculation work.
I want to set tableview cell height automatically to show the label completely without happening like that?
Any help?
There are 2 things that you need to do:
1st thing: Set AutoLayout for it.
2nd thing: implement these code:
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 100
You can see more from my project: https://github.com/khuong291/Yelp