How to populate Dynamic UITableview Inside dynamic UITableviewCell in swift? - ios

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!

Related

nested tableview with automatic dimension

I have a TableView that its cell contains a second TableView (Nested TableView).
Inner tableView shows comments that have variable cell height. Calculate this height with UITableView.automaticDimension.
But main tableView cannot calculate it's cell height properly.
Main tableView use UITableView.automaticDimension for calculating cell height. but innerTableView doesn't show in the main tableView.
My test project download link:
dropbox.com/s/woieoi71t5kt66d/NestedTableViewTest%202.zip?dl=0

Resize tableview cell by updating table datasource dynamically

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

Nested UITableView With Automatic Dimension

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.

Auto set height of table view based on UICollectionView inside it

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.

Dynamic Height for UITableview

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

Resources