Search code examples
xcodeios7popupuipopovercontrollerpopover

Simple Popover View for iPhone with Storyboard


I am trying to create a very simple popover view for iPhone (not iPad) to act as a Help screen for my users. I am using a storyboard and have set my second view (the popover view) size as "Freeform" and set the size in the Size Inspector to 300 x 300. I have a button in the first view that I would like use to segue to the popover view. BUT HOW?

I guess while I'm at it, I'd like a button on the popover view to return to the main view.

I don't need fancy scrolling popovers, I don't need fading backgrounds. I just want a simple way to get to the popover view. Can anyone help???


Solution

  • You can try using the CWPopup, its simple and very easy to use just like you asked. You can find it here: https://github.com/cezarywojcik/CWPopup. I know you asked for storyboard, but there isn't a way to do that. Doing it in code is the only way, and it's very short. It's easier that you think.

    I will break down the instructions for you.

    1) Import the directory CWPopup into your project. It contains the UIViewController categories.

    2) Add this with your imports: #import "UIViewController+CWPopup.h"

    3) Make the popover show up:

     SamplePopupViewController *samplePopupViewController = [[SamplePopupViewController alloc] initWithNibName:@"SamplePopupViewController" bundle:nil];
    [self presentPopupViewController:samplePopupViewController animated:YES completion:nil];
    

    4) Dismiss the Popover:

    if (self.popupViewController != nil) {
    [self dismissPopupViewControllerAnimated:YES completion:nil];
    }
    

    It's very simple. Just a few lines of code. Exactly what you were looking for.