Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bizz84/1f43f6790dbce9d0e2bf031cd4805a94 to your computer and use it in GitHub Desktop.
Save bizz84/1f43f6790dbce9d0e2bf031cd4805a94 to your computer and use it in GitHub Desktop.
class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBAction var sourceButton: UIButton!
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "SlideshowPopoverSegue" {
let contentViewController = segue.destinationViewController
contentViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
if let popover = contentViewController.popoverPresentationController {
popover.delegate = self
// Set the sourceView and sourceRect so that the popover knows
// where to position itself
popover.sourceView = sourceButton
popover.sourceRect = sourceButton.bounds
}
}
}
// MARK: UIPopoverPresentationControllerDelegate
func adaptivePresentationStyleForPresentationController(
controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment