1

Was looking for a swift based tutorial. My solution to the question is below

Hope it helps

Ace Green
  • 381
  • 5
  • 29

2 Answers2

5

* Updated Answer *

class ViewController: UIViewController, UIPopoverControllerDelegate, UIPopoverPresentationControllerDelegate {

    @IBOutlet weak var RoutineLabel: UIButton!

    @IBAction func RoutineButton(sender: AnyObject) {

        switch SDiPhoneVersion.deviceVersion() {
        case DeviceVersion.iPad1, DeviceVersion.iPad2, DeviceVersion.iPadMini, DeviceVersion.iPad3, DeviceVersion.iPad4, DeviceVersion.iPadAir, DeviceVersion.iPadMiniRetina:

            var popoverViewController = self.storyboard?.instantiateViewControllerWithIdentifier("RoutinesTableViewController") as UITableViewController
            popoverViewController.modalPresentationStyle = .Popover
            popoverViewController.preferredContentSize   = CGSizeMake(300, 300)

            let popoverPresentationViewController = popoverViewController.popoverPresentationController

            popoverPresentationViewController?.permittedArrowDirections = UIPopoverArrowDirection.Up
            popoverPresentationViewController?.delegate = self
            popoverPresentationViewController?.sourceView = self.RoutineLabel
            popoverPresentationViewController?.sourceRect = CGRectMake(RoutineLabel.frame.width / 2, RoutineLabel.frame.height,0,0)

            presentViewController(popoverViewController, animated: true, completion: nil)


        default:

            println("iPhones")

        }

    }
}

Notes:

  • my PopPoverViewController is a UITableViewController
  • I use SDiPhoneVersion.deviceVersion to check for device version
  • I use a button to trigger it
  • I make the start of my pop up depend on RoutineLabel.frame
Ace Green
  • 381
  • 5
  • 29
2

I won't pay to get past the paywall in the link you've given, but you're looking for UIPopoverController.

I also don't intend to write out a tutorial here--there are plenty of those available. A short and simple example of creating and using a UIPopoverController is given in this similar question: UIPopoverController, Xcode 6, IOS 8 using Swift

Community
  • 1
  • 1
GarlicFries
  • 8,095
  • 5
  • 36
  • 53