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.
Related
I am trying to make a custom TableViewCell for a tableview, and the size is 414x350. The problem I am having is when table view get loaded all the sizes are squeezed and not right. I have tried all of the followings:
Assigning row height from code
tableView.estimatedRowHeight = 350
tableView.rowHeight = UITableView.automaticDimension
Assigning row height from storyboard in tableview window
Assigning row height from storyboard in tableviewcell window
The result is still the same. Any help is appreciated!
For any cell's automatic row dimension to be calculated properly, in your Storyboard you must have a direct line of vertical constraints between every item that goes all the way from the top to the bottom. If you set the constraints yourself, same thing applies.
Don't assign any row heights, except the estimated.
I need to implement the dynamic UITableView inside dynamic UITableviewcell like the below screenshot. Also, all values are dynamic which is coming from the server.
yes exactly you need inner tableview to do this.
first you have main tableview with card layout cell this should be dynamic cell height.
in this cell you have topview, inner tableview, bottom view all this view you can take fix height as your layout i see e.g top view is 80 height, bottom view is 80 height and tableview has dynamic height based on number of cell like cell height is 100 and you have total 3 cell so table height is 300 you need to make outlet of tableview height and update it programmatically.
hope this helps you!
I'm displaying information fetched from a server on tableview. My tableview cell view has two vertical stackviews placed horizontally in a content view. Each stackview has 6 items and depending on data I'm hiding and showing the stackview item and setting the stackview and content view height depending on content of stackview visible items. This is all working fine and the tableview is also looking good.
Now I have a feature to delete tableview rows on swipe of a tableview row. So after deleting any row and reloading tableview cells, tableview cell height is not getting set and shrinks.
Can anyone help me with how do I update tableview height after each reload? I've tried all possible solutions but none of them worked to me.
Try the following, in your viewDidLoad set:
tableView.estimatedRowHeight = 60 // this is an estimation but try and get it close to what the actual height may be
tableView.rowHeight = UITableViewAutomaticDimension
Then in the tableView heightForRowAt indexPath return this:
return UITableViewAutomaticDimension
I have a screen that contains 2 levels of nested UITableViews.
Each cell of the outer (top level) TableView is a UITableViewCell That contains a UITableView.
The TableView inside each cell is drawn correctly, all constraints implemented properly UITableViewAutomaticDimension is performing correctly.
The problem is with the top level TableView cells height, Im trying to set their height with:
table.estimatedRowHeight = 400
table.rowHeight = UITableViewAutomaticDimension
and also return UITableViewAutomaticDimension in heightForRow.
Cells get height of 45 when their height is 400 or so (dynamic height for each cell).
What am I missing here?
Could it be that the top level TableView just cant estimate the inner cell height?
Help would be much appreciated
Have a look at this Tableview Inside Cell . It contains table view inside cell that is completely constructed using auto layout. Hope this may help.
i have a tableview with a dynamic changing number of cells. sometimes there are 10, another time more than 20 cells.
This Tableview is on a Viewcontroller, but i have so much content on this tableview, so my tableview and all other content are on a scrollview. now i have a double scroll. on on my scrollview, and another on my tableview and this is quite uncomfortable. so how can i set the height of my tableview dynamically?
If you are using Autolayout with storyboard then set constraints of your tableview
let Count = CGFloat(dataArray.count)
constraintsTblHeight.constant = Count*100 //100 is your tablview's cell height
other wise increase this height in tablview height