slowlobi.blogg.se

Swiftify alex petuschak
Swiftify alex petuschak












swiftify alex petuschak
  1. SWIFTIFY ALEX PETUSCHAK HOW TO
  2. SWIFTIFY ALEX PETUSCHAK CODE

If we’re on an iPad, it will now be shown in a Popover. And that’s it: now iOS will show our content. instantiate with our content view controller, set the delegate, anchor point, etc). We need to create a UIPopoverPresentationController object and configure it (i.e.

swiftify alex petuschak

Now we show the view controller, even though it won’t be presented until we’re done with our next step. This tells iOS that if possible, we want to see our content presented as a Popover.

swiftify alex petuschak

Next I’m setting the modal presentation style of my view controller to UIModalPresentationPopover. On iPhone, we could go ahead and present the view controller at this point, but because we want to be Popover-Compatible, we’ll do a little extra work. Make sure the Storyboard ID is set in Interface Builder so we can reference it. I’m instantiating one from my main storyboard. Here’s what we do step by step: first we grab our content view controller. I have a reference to it, so this following Popover can point its arrow at it: Popovers need an anchor, such as a UIBarButtonItem in a navigation controller. Presenting a Popover from a Bar Button Item To react to the dismissal of a Popover we can implement a delegate. The view controller can have a custom class (for the UI and logic that’s presented therein), while the presentation controller does not require any additional code. The concept of a Popover is still the same: we need a content view controller that’s displayed inside the Popover, while the Popover itself is a different object (now called the Popover presentation controller).

SWIFTIFY ALEX PETUSCHAK HOW TO

Let’s see how to create a simple Popover Presentation Controller in iOS 9. Both the creation as well as dismissal process have been streamlined, and I find it’s now actually a joy rather than a chore to play with Popovers. While this approach was optional in iOS 8, the UIPopoverController is now deprecated and should no longer be used in iOS 9 (and good riddens I say).

SWIFTIFY ALEX PETUSCHAK CODE

No other code change or if-then query is necessary. The great news for us developers is that we no longer have to check what type of device we’re on and present our content accordingly: we simply present a Popover, and if we happen to be on an iPhone, iOS will automatically show our view controller as an action sheet instead. It’s available on iPads as well as iPhones. IOS 8 introduced a new way of creating Popovers on iPad: instead of using the trusty old (nightmarish) UIPopoverController class, we can now use the UIPopoverPresentationController.














Swiftify alex petuschak