2 CollectionView inside the TableView Cell not working - swift

I'm working on ui that has basically two categories first is categories and second one is products when user click on any category the products load accordingly.Category showing in horizontal direction and products showing in vertical direction.I'm using tableView and inside the tableView cell I'm using two collectionViews.All outlets are connected when I running code (could not dequeue a view of kind: UICollectionElementKindCell with identifier CategoiresCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard") occurs.Also I'm using tableView height method I' want dynamically calculated and also in collectionView I'm using sizeForItemAt for calculating the height so how I can calculate the dynamically height accordingly to content in tableView as well as in collectionView according to tableViewcell.
I want this layout
My code pics
Error:

We have had the had the same problem with sizing of TableViewCell and dealing with accessibility large font and collection views, the way we got around that was to get the table view cells to to relayout there contents a second time, it seem like the cell needs to layout there subview again with something like layoutIfNeeded, it was a work project, so I don't have access to anymore and can only go by memory, but hopefully this will point you in the right direction.

Related

Nested UIStackViews in UITableViewCell not working with constraints

I have a simple table view controller. Section 0 will be a single cell with a couple of labels, textfields, and a few buttons. I wanted to use stack views to layout the fields neatly. The moment I add any constraints I get the whole thing off the cell and not visible. The one button that is alway visible isn't even the correct width. The cell height is plenty large enough to hold it. It looks perfect in the interface builder, and has no errors or conflicting constraints. What am I missing?
Then image with the fields all there is without any constraints.
In the Interface builder
ScreenShot

Two UICollectionView inside UITableView not UITableViewCell

I found this post here : http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/
But,unfortunately,this doesn't meet my requirement.It was here.
My flow is similar to the one at App Store.But,What I am gonna do was implementing pull to refresh and pull up to load more at top and button of UITableView.
I can include both two UICollectionView at the UITableView.But,I can't resize second UICollectionView as the data included in its datasource.
Please take a look
As you can see there was 5 blue block at second uicollection view.But,they are not showing properly.Its there anyway that i can fix my collection view data by resizing uicollectionview?
Because second collection view data will be dynamic as soon as I implement pull to load more below at uitableview cell.So,i disable the second collectionview vertical scrolling.But,I want to appear all the items at second collectionview.
Any Help?I can provide sample if needed.Thanks.

Custom cell in UITableView

I am making a custom cell which has text fields and as a result the custom cell is greater than the size of the iphone screen.But i am not being able to do horizontal scroll to reach the end of the cell.
I have tried using viewController and adding table view to it as well as creating table view controller and adding custom cell to it.
when doing it through TableViewController,I am not able to horizontally scroll it,whereas i am not getting how to add Custom cell class to the tableView object placed in viewController.I know that UITableView is a subclass of UIScrollView but not able to implement it.Please help.
Thanks
as per the documentation at
A table view in the UIKit framework is limited to a single column
because it is designed for a device with a small screen. UITableView
is a subclass of UIScrollView, which allows users to scroll through
the table, although UITableView allows vertical scrolling only.
so as desired in your case you will have to take some other approach. Now using Custom cell with TextFields should not actually need you to require Horizonatl scrolling. If the text is really large you would like to consider using TextView instead of TextFields.
Hope it helps
Ideally, you should be truncating your text. But if it is important for you to display the entire text, add a scroll view as a subview (or set it as the content view) and add your labels to the subview. Each cell will then be individually horizontally scrollable.

Content of custom table view cells not drawing correctly

I have several parts in my app where I use custom table view cells.
Their content is created with subviews.
The problem is that on some of these cells, the content does not appear at all or does not appear correctly until after the cell was selected for the first time.
One example is a custom cell which has a custom subview which can be set after its creation. This view does not appear at all before I selected the cell and its views were redrawn. Calling -[setNeedsDisplay] in the subview's setter method does not help either.
The problems was that I was using the cells themselves to calculate their height. For some reason, the subviews (which were part of the cell used to calculate the height) weren't appearing correctly in the cells that were used for the actual displaying.
Therefore my advice: Never use a UITableViewCell to calculate its own height. This may work in principle (it doesn't crash), but might bite you later in unexptected and hard-to-debug ways.

A UITableView followed by several buttons- any way to size the table view to fit a variable number of rows?

In Interface Builder, you have to set the size of the tableview and position the other elements beneath that. I want the tableview to be sized to fit any number of rows and the buttons to be moved down relative to the tableview.
Is it possible to do this without building the whole thing programmatically?
You should embed the buttons within a UIView, and set that UIView as the tableFooterView of the UITableView. You can do this in IB by dragging the view into the bottom of the UITableView. This way the buttons will always be below the last row of the tableview, though I should warn you that if there are more rows than fit on-screen, the buttons won't be visible until you scroll down. If this isn't what you want, then you'll need to do something more complicated (namely, run -layoutSubviews on the UITableView, then ask it for the rect of the last section, and use that to calculate where the buttons should go).