How to add many Popovers in one View (iPad)? - 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.

Related

Adding a UICollectionViewController inside another UICollectionViewController

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.

How to add view in top of view hierarchy in Swift?

I have been using this:
UIApplication.sharedApplication().keyWindow?.rootViewController!.view.addSubview(self.customView)
To add a modal view over all the views in the view hierarchy in app.
But this is giving me problem. It adds subview as expected sometimes but sometimes it doesn't' work.
In what case this wont work and what's the best way to add modal view in view hierarchy like UIAlertView.
Depending on what's happening, there can be more than one UIWindow at a time - for example, if a system alert shows up, you will have two separate windows (one for your view controller, one for the alert itself).
A similar example can be made for the system keyboard. If the keyboard has focus, that will be your keyWindow.
A way of making sure you are adding the subview on top of all windows, could be: UIApplication.sharedApplication().windows.last?.addSubview(yourSubView).
I've also seen people using the application delegate, with: UIApplication.sharedApplication().delegate?.window.

Multiple States in Xcode 6 Storyboard. Animating/Moving items in run time

I have made various attempt to go storyboard only and limit my code when it comes to UI. Everytime I was getting stuck and reverting back to code. Since the release of XCode 6 and the new iPhone that have multiple screen sizes it make more sense that ever to go Storyboard only.
This time I am stuck on the following scenario. I want to create a custom search view controller that will have 2 states:
Search State. It will prompt the user for a keyword to search.
Result State. It will display the results to the user.
I am aware that this can be accomplished using the UISearchController, but the customer wants to customise the behaviour. Currently I have two view controllers and a push/show segue between them. I would like to replace that with one view controller and animate the display of the results.
Is there any way that storyboard can accomplish that. I am thinking of creating two view controllers (in storyboard) with different layouts. Both will be linked on the same class. I could create a segue between them, but then I will lose all the variable stored inside them and will not be able to animate between them.
On the transition between the two states some UI elements will be hidden and some others will be moved. I would like that to be animated.
I know how to do that in code without using storyboard, but then I will have to cover all different screen scenarios. I hope there is an alternative way.
You can do this with two view controllers, and set a segue between them. The trick is that the animation bit will have to be done in code, unless you write a custom UIStoryboardSegue to handle the animation.

Best practice to develop common header view across all controllers/windows in iOS app

I'm keeping on developing an iPhone app (rigth now native one) and I would need to use a common "header" for all views but I don't want/need a UINavigationBar and prefer much more have a common "partial view". It will have some actions to perform but always the same ones (showing notifications panel, basically). It should be something like you can see in the screenshots.
I don't need (I feel) delegation because the controller's view can handle notifications and show them when user clicked the customize button.
I don't mind to use a Nib o make the view hardcoded but I'm not sure how I must make an instance of the view or the controller that handles it within each app tab (I'm using UITabBar as navigation control).
From my point of view it doesn't exist a way to get a common controller to call wherever needed; you just can use some method to present new controller as modal o push it out and I think that is not what I'm looking for.
Any idea is welcome. Thanks
Create a custom view controller with 2 subviews. Subview 1 is the header. Subview 2 is the container view where child view controllers are displayed (your tab bar controller in this case).
Your custom view controller could be the delegate of the tab bar controller if you want, so it can be notified when the tabs change and update anything on the header view.
Well, finally is have used the solution I found on the link http://patientprogrammer.wordpress.com/2012/03/12/re-usable-subviews-in-ios/
I have created a Nib with a view controller and then, in the main window I have added two view, the top one subclasses the view controller for the Nib view and it is rendered automatically when app is launched without a single line of code within "main" controller. See the screenshots for more detail:
Thank you very much for your help

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

Resources