How can I create a popover in an iPad Storyboard for an iOS 5.0+ app?
There's already one setup with the Xcode Project Template (Utility App), but I can't seem to figure out how Apple got it to work. I tried to mimic it, but only got errors. I even looked on Apple's Dev Site, but only got out-dated code that resulted in warnings and build errors.
I have a CBMainView
and a CBMasterView
(with the exception of the master view already included), and a UIToolbar
with a UIToolbarButton
. I need the user to tap the button on the UIToolbar
, and up comes my 320x300 Popover (CBMasterView
).
How can I do this with Xcode Storyboards? Tutorials, answers, code, or links are all appreciated!
I'm also looking for the answer to this problem. I did solve it using NSNotification.
Here's how:
The View Controller that displays the popup should register to receive the notification:
languageSetup
is the function that will be called,SPVWChangeLanguage
is a string that you will define in your popup view controllerI added this line in
viewDidAppear
Now in your popup view controller add this line when the user selects something in the table:
before dismissing the popup:
That's all. The selector languageSetup (in my case) will be called. Be sure to remove the notification when your view controller goes away:
I do it in
viewWillDisappear
I think there must be an easier way. But at least, this one works for me.
Before iOS 5, one would've needed to display another
UIViewController
using the First Responder via a Modal presentation (and a pile of code).To create a popover in Xcode's Storyboard Mode (iOS 5+) use a
UIButton
orUIToolbarButton
and create a Storyboard Segue between the button and theUIViewController
that you want to pop-over.Creating a segue between a button and another
UIViewController
is simple. Here's how:UIViewController
of choice. You should see a light blue line appear that extends from the button to the tip of your mouse.After dragging the blue line to the ViewController of choice a small black menu will appear. This menu displays the different segue options. Select
Popover
.If everything was done correctly, this segue should be visible in the Connections Inspector when the button is selected:
The
UIViewController
you create should also have a custom size that is smaller than the full screen. You can set a custom size by selecting the View Controller and setting its size property tofreeform
, ormaster
(320 x 850).If you use storyboard with IOS8, take a look at this post, answered it for me!
How to present a modal atop the current view in Swift
In short: You make a separate popup view, give the background a color with low (or none) opacity, and connect from your main view to the popup view, with a modal segue.
Then in storyboard, click on the segue, and then in the attibute inspector: change presentation to "over current context" (and maybe transition to cross dissolve, if you use an opacity that is more than 0)
Easiest way i have seen so far!