I'm new to swift and trying to understand how to use UIPopoverPresentationController
.
What I need in my app is that when a button is pressed a popover from the button of the screen will be shown on with an xib file on half of the screen . What happens now is that I manage to segue to the second view controller but don't know how to load the xib file and how to make the popover to be an half of the screen from the button. this is my code
import UIKit
class BaseViewController: UIViewController , UIPopoverPresentationControllerDelegate {
@IBAction func moveToPopoverView(sender: UIButton) {
var popoverViewController = self.storyboard?.instantiateViewControllerWithIdentifier("Popover") as! UIViewController
popoverViewController.modalPresentationStyle = .Popover
popoverViewController.preferredContentSize = CGSizeMake(200, 200)
let popoverPresentationViewController = popoverViewController.popoverPresentationController
popoverPresentationViewController?.permittedArrowDirections = .Any
popoverPresentationViewController?.delegate = self
presentViewController(popoverViewController, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
}
}