I have project with structure like:
-scroll view
--view
---collection view
----collection view cell
-----table view
------table view cell
This structure is necessary for this project.
Every things works correctly like scroll view, collection view and table view but there is interaction just with index 0 in collection view.
In other words didSelectRowAt method just call in index 0.
And i have uploaded my project on GitHub:
https://github.com/reza-khalafi/ScrollCollectionTable
Please help me to fix this problem.
Thank you
To fix the offset try using an auto resizable cell for UITableView
so in setTableViewDataSourceDelegate method just call
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 300
Related
I'm trying to display a UITableView inside a UICollectionViewCell, that would be displayed over the other cells.
(The other cells don't have a table view)
Here's what I get so far :
Result : The UITableView is displayed behind the other cells.
I've set clipToBounds = NO to the content view of the cell, so that the table view gets displayed outside the cell content.
After looking at the View Hierarchy inspector, it seems that the cell containing the table view is lower than the other cells. I think it should be on the same level ?
Any help would be appreciated, thanks !
I found a solution that is working for now :
self.layer.zPosition = 1000;
(Inside UICollectionViewCell)
I have a collectionView laid out in the storyboard like so:
Note the constraint: Collection View.top = Search Bar.bottom
I don't want any of the content in the collection View above that line. However when the app runs and you scroll the collectionView, this is what happens to the cells. What could be happening here?
Probably collectionView.clipsToBounds = true
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
here need some help T_T.
I'm design a page that use a collection View to display 4 different table view in 4 collection view cell. Therefore I design collection view in xib and put a table view in it, but in this case tableview have no prototype cell when it is designed in a collection view cell in xib , so I create another xib to handle my tableview cell.
The problem is , when Im adding "estimatedRowHeight" and "AutomaticDimension" in cellForRowAt below
let backgroundCell = detailCellTableView.dequeueReusableCell(withIdentifier: "baseDetailTableViewCell") as! BaseDetailTableViewCell
backgroundCell.setTitleLabelText(title: backgroundTitle)
backgroundCell.setContentLabelText(content: background)
self.detailCellTableView.estimatedRowHeight = 300
self.detailCellTableView.rowHeight = UITableViewAutomaticDimension
return backgroundCell
it would be none change tvcell
The cell size won't autosizing , the label in my custom cell is stacked.
I guess that the problem might be the prototype cell , but I don't know how to solve it..
This is because, this property is added to the tableview and you are adding it to cell.
Steps:
1) Create a tableview outlet.
2) add following code in viewdidload()
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 300
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.