4

I'm wanting to implement a custom popup window within an iPhone app that contains buttons and labels.

One solution I've found is to simply create a hidden UIView in the same View Controller (How to make a popup window with an image SWIFT) and then making hidden = false. I feel like this shouldn't be the "best" way to do this, just due to the way I'll be working with multiple interfaces in the same View Controller.

Another method is forcing a non-fullscreen popover on iPhone (http://richardallen.me/2014/11/28/popovers.html), but this doesn't seem to play well with containing other elements like buttons and labels.

Is it possible to create a custom popup window for iPhone - which can hold buttons and labels - that can be implemented from a separate View Controller in my Storyboard? It has to be in a way that doesn't hide my main UI behind a fullscreen popover. Preferably one that can be easily animated using UIView.animateWithDuration.

Just looking for some starting directions so I can go learn more about implementing it. Or is stacking it with my other UI in the main View Controller the best way to go?

Community
  • 1
  • 1
ADRSPR
  • 111
  • 1
  • 3
  • 8
  • You can create full screen view controller with transparent background like here http://stackoverflow.com/a/28875789/1422333 – Zell B. Mar 09 '15 at 11:23
  • Nice. That works well enough for now! Thanks for the simple solution - I don't know why I couldn't find that anywhere. Next step will be detecting a tap outside of the small window I create to close it. Thanks again. – ADRSPR Mar 09 '15 at 11:38
  • A simpler solution is to present the UIPopoverController (btw, handling out click to dismiss the popover is done automatically without need to detect touch events to dismiss): https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIPopoverController_class/index.html – Malloc Mar 09 '15 at 12:23
  • `UIPopoverController` depricated in iOS 9.0 – Mixaz Aug 28 '15 at 09:55

1 Answers1

0

add a UIView container and make it's alpha = 0. If you want to show it you can increase the alpha to 1. And simply add a exit button to your container to decrease the alpha to 0.

do it better
  • 4,627
  • 6
  • 25
  • 41