Good evening! I want to put one table view inside cell of another table view. And inside main table view cell self sized collection view and below should be another self sized table view. But XCode want to add height constraint to collection view above or to table view below. But I need to set "wrap content" to both of them. How to do it? Please help!
Related
I have a tableview. Right now the first cell will begin right at the top of the tableview, but I want it to start some number below the top of the tableview so that I can addSubview() in that spot without covering content in the first cell.
Below you can see what I want to achieve.
The rectangle in the center represents the cells, the line at the top represents the top most of the tableview.
Short answer: You don't. The contents of a table view belong to the table view. You should not try to add subviews to a table view.
As #rickramirr says, you either need to position your table view lower on the screen, or use a header view that contains the contents you want.
(If you decide to position your table view lower down, need to either not manage your table view with a UITableViewController, or have a UITableViewController as a child view controller of the screen's main view controller. A UITableViewController is kind of dumb, and only knows how to manage a table view and nothing else.)
I think that maybe you should add a custom header to your table view or put another view above your table view. Here is Apple docs to customize your header: https://developer.apple.com/documentation/uikit/views_and_controls/table_views/adding_headers_and_footers_to_table_sections
All the views that you want to insert between one tableView cell and another must extend UITableViewCells too. You can create custom cells by defining a new xib file containing a UITableViewCell, whose content could be whatever view you want. Then, you must create a swift file that extends UITableViewCell associated with the xib file. Finally you need to record that cell into the table, either programmatically or by manually inserting it into the storyboard within the table. At that point you will decide its position using the UITableViewDelegate "cellForRowAt" method.
There is a main table view and inside each of the main table view cell has their own header table view. Then each of the header table view cell has their own sub-header table view. All the table rows don't have fixed counts according to the dynamic data. What I try to achieve is when a cell of the main table view is expanded, I should see the header table view cells unexpanded. After a header table view cell is expended, I should see the sub-header table view. I need a solution without using libraries.
I provided the storyboard UI based on what I want to achieve.
To deal with expandable cells (or cells inside cells effect) I recommend using UIStackView inside UITableViewCell and add inside needed views with data.
For example you can create UIView inside Xib file and load it inside needed UITableViewCell then add to UIStackView and fill with data.
Then you can simply hide/unhide elements inside UIStackView to archive expanding/unxpanding.
This way or other you should use 1 UITableView.
I once made a 1 step expandable Table View.
Here is what I did to achieve that.
Do not make different table views for each hierarchy. That will be difficult to manage. Instead, make one table view but change the type of cell you want to show. If the cell is top level cell or first level cell or the second level cell, change the design of each one that.
The data source will then have list of list of list to denote the 2 level expandable UITableView.
To open and close the table view, you can simply change the data source and reload or use beginUpdates and endUpdates
I have a problem with accessing collection view cells inside a table view cell when using app.debugDescription during XCode UI Test runs.
First of all, XCUIApplication proxy do not see any collection views, but there are 4 of them, 2nd it does not see any cells other than the 4 cells of UITableView.
I have tried setting isAccessibilityIdentifier to false on these table view cells, but no use. If I set isAccessibilityIdentifier to true for each collection view, then I can see 4 collection views, but still no cells. I have put accessibilityIdentifier values to each cell in collection view and on elements inside a collection view, like UILabel and UIImageView.
If I set isAccessibilityIdentifier to true for collection view cells, then I can see accessibilityIdentifiers for each cell when printing out app.debugDescription, but as other element, not as of cell type.
Can anyone assist me here, here is my screenshot of view hierarchy in the storyboard.
Scenario -
I have a table view on which I have added custom views by tableView.addSubView(myView).
Now I have a certain cell whose contentView needs to be shown above tableView.
Methods Tried
I tried passing a tag on the cell's contentView and iterating on all table view's subView's. But that didn't help out.
How to move a cell's contentView above any other sub views of table view?
I am creating nested table view. One table view for vertical scrolling. And another for horizontal scrolling inside the cell of first. I set the delegate of horizontal table view to vertical table view's cell subclass. But the problem is that the horizontal table view's delegate methods aren't calling.
Does any one have an idea why its not calling?
You have to make sure that you are setting the delegate programatically when configuring the cell that contains the second tableview.
Can you post some code...