Reputation: 391
Was looking for a swift based tutorial. My solution to the question is below
Hope it helps
Upvotes: 1
Views: 8186
Reputation: 391
* 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:
Upvotes: 5
Reputation: 8323
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
Upvotes: 2