How to add uicollectionview inside uicollectionview header - ios

I need to know how I add a collectionview within the header of the collectionview 'father', I have tried it in several ways but it does not work for me.
something like the following image:

You can achieve this using a separate xib file that will represente your header and than adding the new collectionView in it.

Go through below steps:-
Take two nib one for normal cell and one for header cell.
In Header cell take collection view
Decide which nib you have to load in cellForRow method using boolean flag or something else.
You need to define your own logic.

Related

Xcode interface Builder doesn't give me option where to put reuse identifier for a UITableViewCell

I've created a new xib by New File->View. So, I put a name for my class which is a child of UITableViewCell.
But in the next inlay there is no option of where to put in a reuse identifier.
I tried this several times and it's all the same. Could anyone suggest me how to fix it?
create UITableViewCell like this bcs you take the uiview and extend the tableviewcell class
see second image you have UIView not cell
it looks like you selected something else, Not TableViewCell
Please see below screenshot
If you have want to set Reuse Identifier for cell, then must use cocoatuch file with xib select see below image. You can't create seperate xib, coz xib file have no any property like Reuse identifier.

I need help knowing where to start on designing a tableview or if a tableview is what I need

As in title, I don't know where to start with creating a view like this. Do I hard code it or use XCode editor? Is a table view what I need?
Yes, a UITableView is what you needed.
You need to create a TableView Controller.
Follow by creating a TableViewCell
Then you need to start coding. Hook up the delegate and data source methods.
For more information, check this tutorial by Apple:
https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/
Here you have a tableView with section header indicating the date of the matches, the tableView has a custom designed cell, each cell contains the names of the two competing team.
start by adding the tableView to your viewController using storyboards, with the delegate and datasource connected.
the sub class from UITableViewCell and create your custom cell with an xib file.

How to reuse UITableViewCells

I have 2 viewcontrollers on my storyboard, which both have a tableview. Now I would like to implement the same cells in both tableviews. Is there a way to easily reuse these cells across multiple viewcontrollers?
Yes you can use it by using custom table view cell
Example for custom table view cell
You should reuse full UITableView for this case. There is no open API for sharing cells between multiple UITableViews, but you still can reuse UITableView in case there is no moment when two controllers are shown simultaneously.
Yes, It's possible you need to create .nib file with subclassing UITableviewCell
take a look on https://medium.com/#musawiralishah/creating-custom-uitableviewcell-using-nib-xib-files-in-xcode-9bee5824e722#.u8xounci2
you get to know , how to create & use .nib file.

Register multiple header supplementary view in the same UICollectionView through storyboards

So I have a UICollectionView that I want to use to display multiple UICollectionViewCells and different headers depending on the state the user is in. The problem is I can't seem to register multiple UICollectionResuableView (header) views within the storyboard. If I try to register one as a footer and use it as a header the app crashes. I also do not see anywhere in the storyboard to declare the number of sections, which would alleviate the problem. For now I'm having to use multiple UICollectionViews and hide/unhide the collectionview I want to display based on the header I need. Is there a better way to do this, or a way to register multiple header views in the same UICollectionView within the storyboard?
You cannot register more than one header in a UICollectionView in a storyboard, but you can register an arbitrary number of them in code. You should create however many headers as you want in nib files (One nib per header, with the header as the top level object), and register them with your collection view instance in viewDidLoad.
You would do this with the registerNib:forSupplementaryViewOfKind:withReuseIdentifier: method.

Custom UITableViewCell using storyboard with some cells

I have a TableView in which a most cells are pretty standard. I make them buy using static cells in Storyboard. However, one cell I would like to customize probably using an XIB file so I would need to load it programmatically.
In the TableView's data source, is it possible to handle loading XIB view for this particular cell only, while leaving other cells to what's delineated in the static cells in the Storyboard? Or is it an all or nothing thing where I need to just give up using static cells altogether?
The rationality for doing this is that I would like to make Storyboard to look as close to the real thing as possible. Right now if I provide a data source, the static cells in the storyboard would have no effect on the actual output and is not in any sense linked to the actual output.
Yes, it is possible. Set the custom class for the custom cell. If you wish to customise it from code, just connect it as an IBOutlet to the UITableViewController.

Resources