Adding a UICollectionViewController inside another UICollectionViewController - ios

I am writing a project where I need to display a list of players (avatars) in a horizontal collection view controller / list, let's call this a HUD.
I want this HUD to be common, that is to say: I know this one component will repeat many times throughout the app.
I do not want to write the Collection View code over and over again.
I want to add the collection view to an existing view controller which already has a collection view.
Almost like an in-line Master-detail display where the master does not change from page to page.
Is there a way in Swift where I can instantiate the HUD collection View and append it to whatever View Controller I am in.
I have included a picture.
Thus my query is this:
How do I include a collection view controller inside another View controller that already has a UICollectionViewController?
How do I share this HUD component across multiple screens in the app?
Many thanks

I used a container view to solve my issue. This issue is now closed.

Related

In Xcode, how would you go about having view controllers which are only accessible to the user if they perform a certain action in the app?

The app I am making has multiple pages which the user swipes between. I need the user to be able to press a button and that create a new page in the app, and then also for the user to be able to delete that page of the app. Is there a way to generate/delete a view controller while the app is in use? Or do I need the view controllers already to exist and somehow lock/unlock them when the user adds/deletes them?
You don't have to create all the view controllers already and somehow lock/unlock them when the user adds/deletes them.
You can use UIPageViewController for this purpose. Using UIPageViewController you will able add and delete view controllers.
Another way of implementing the same feature without the use view controllers as page is by using a UICollectionView with its cells as page and paging enabled. Here in this case the size of the collection view cell be same as the size of the screen.
To have a snapchat like multiple view controller you could probably use a UIPageViewController with your custom views or a scroll view with paging enabled.SwipeView also seems like a nice implementation. see this stack overflow post for some other options and some implementation methods.

How to create simple tableview and load data using Swift in iOS

I am trying to create an app for iOS using Swift but running into problems with the very basics.
To keep it simple I just want the app to initially be a single view application with a button and some sort of list view on the page. I believe a TableView is what is recommended here. When I click the button, I just want it to populate the list/table view with some entries, that's it. To start with, I don't care if these entries are hard-coded, I just want to get something working.
I have been looking at different samples but I am getting confused. Some of them seem to suggest using a TableViewController others don't. When I use a tableview controller, the UI I had created seems to get completely replaced with just an empty tableview list and the button is gone.
I previously have developed apps in Windows phone and found it a lot easier. I'd just add a listview object and in the click method of button, add the items programmatically etc. But this is my first time trying to create an iOS app and it seems a lot more confusing. There are delegates, controllers, views all seemingly needed in order to do something very simple.
Can anyone give me some basic step by step instructions about how to add a tableview to an application and load some data into it through a button click?
Make sure you are clear about the difference between a view and a view controller.
iOS uses the MVC design pattern (Model View Controller).
A view object displays contents to the user and responds to user interaction.
A model object stores state data.
A controller object drives the app logic and mediates between the model and the view.
A UITableViewController is a special subclass of a UIViewController who's job is to manage a table view. It has some extra support in it that makes it a good choice for managing a table view, BUT... there is one annoying thing about it. It is designed so the ONLY view it can manage is a table view. You can't use a UITableViewController if you want to add buttons, labels, and other UI elements to your screen outside of the table view.
What I usually do is to create a create a table view controller, create a separate regular view controller, add a container view to the regular view controller, and then use an embed segue to embed the table view controller inside the view controller. (you just control-drag from the container view to the table view controller.) That way you get the best of both worlds. You may want to create a protocol that the table view controller would use to communicate with it's parent view controller.
You should be able to find a tutorial online on setting up a table view controller as a child of another view controller using container views and embed segues. It's quite easy.

UzysSlideMenu: how to use several view controllers?

I just came across a slide-in menu I really like: https://github.com/uzysjung/UzysSlideMenu
I would like to use this menu for an application that uses several view controllers (UIViewControllers and UINavigationControllers).
In Xcode, I created a single view application and made the view controller (MenuViewController) show the menu, like the creator did in his example project. I added more view controllers to the storyboard and connected them via segues to the MenuViewController. Upon selecting a menu item, these segues are triggered and the selected view is shown - so far so good.
But now, I run into the following problem:
All my view controllers are shown in full screen. That means that VCs that get segue'd in the viewport don't show the menu, because it's just not implemented there. I could put the menu in every VC, but that doesn't seem to be the right way to do it (even if I use some custom delegate method that every controller calls, like putMenuInViewController:(UIViewController *)target). I think I need something like a global singleton for the menu and make it appear in every view controller, but I have absolutely no idea on how to it or what to google for.
Any points into the right direction are greatly appreciated :)
I think you need to implement one root view controller with this menu as singleton, and add other view controller as child view controller to it.
I wrote a post about it, you can find it here:http://antrix1989.blogspot.com/2013/09/uiviewcontroller-as-singleton.html

Creating a spit view app from single view ios

I have run into a snag with changing a single view style app into a split view style app.
I have made it so I have the detail view set to the correct view controller, but dont know how to set up a table view for the master view. I created the table view as its own file outside of the storyboard and I don't know how to add it to the master view.
Also how should I link the two together in my code? The Table View was displayed as a popover in the single view version of the app, and it calls a method from the View Controller when a cell is selected. How would I implement the code to bind them?
Sorry if this seems noobish, but this is my first app and still learning.

How to add many Popovers in one View (iPad)?

How exactly do you show many Popovers in one view? I'm trying to add many of them, just with different arrays. I can show one using a delegate (the Popover has a separate view controller & it's nib).
Thanks
It's easy to stack them. I haven't tried running them in parallel, but this should work: create the first popover and add your current view to passthroughViews, then present the popover. Now you can start the next popover from you base view. Make sure you have a mechanism to dismiss the popovers later.

Resources