RSS Feed

Popovers are NOT Dead on the iPhone

I just spent some time reading and responding to an article that attempted to argue that popovers on iOS 10 don’t work. This is semi-correct: they don’t work intuitively (they never were very intuitive from my point of view).

However, I have an Objective C program that has popovers that have been working quite well.

Here is an image:


The first thing you may say is, “Wow, that looks a lot like a popover” and you would be correct (running on an iPhone 5 with iOS 10.2.1).

However, this guy was writing Swift. So then the question was, could it be done in Swift? Perhaps there was something special and Swift was preventing his popovers to act like popovers?

I eventually found an example here by Bartłomiej Semańczyk and bhnascar. I took it and simplified it a little.

import UIKit

class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
    @IBOutlet weak var bottomButton: UIButton!

    override func viewDidLoad() {

    override func didReceiveMemoryWarning() {


    @IBAction func importantButtonPressed(_ sender: UIButton) {
        let popoverContentController = UIViewController()
        popoverContentController.view.backgroundColor =

        // Set your popover size.
        popoverContentController.preferredContentSize = CGSize(width: 300, height: 300)

        // Set the presentation style to popover
        popoverContentController.modalPresentationStyle = UIModalPresentationStyle.popover

        // Set the popover presentation controller delegate
        popoverContentController.popoverPresentationController!.delegate = self
        popoverContentController.popoverPresentationController?.sourceView = bottomButton

        // Present the popover.
        self.present(popoverContentController, animated: true, completion: nil)


    func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
        // Return no adaptive presentation style
        return .none

This is pretty easy to recreate:

  1. Create a new Swift project.
  2. Put a single button on the View Controller Scene.
  3. Copy (yes, some of it is hidden, but it does copy correctly) and paste the code from above and REPLACE all of the code in ViewController.swift.
  4. Connect the button to the importantButtonPressed method or you will be severely disappointed in me
  5. Run

What should happen is that as soon as you press the button, a blue popover appears. Hooray!

Why do People think Popovers are Dead?

I don’t know. Popovers have never been the easiest code to create, but they aren’t impossible either. Some have said that it is because Apple’s documentation is out of sync with the current iteration of Swift. This may be the true issue—a long time ago I seriously complained about the documentation with OS X beta and Apple asked if I wanted to be an unpaid volunteer to review their docs. That didn’t happen.

And it is true that popovers that work quite flawlessly on the iPad turn into full-screen modal dialogues on the iPhone. Someone at Apple has been paying too much attention to things other than ease of use for the developer.

Or that hobgoblin, consistency.

Anyway, I hope this helps people.


About Catalina Feloneous

Catalina Feloneous (“Call me Cat”) has been writing code for decades. She is very much into justice, software, fashion, humor, and games. She always plays games on Super Easy, much to dismay of her friends. She lives on a wildlife refuge in Texas with her partner and two horses. “Feloneous” is misspelled intentionally.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: