You can override and implement -prepareForSegue: in the source view controller. That method is called when a segue begins and it's where you prepare or customize the segue, or prepare the destination view controller, such as passing it a data object.
In your case, you need to get the destination view controller (the one that'll appear as a popover), cast it and tell it which UIBarButtonItem to use as an anchor.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let vc = segue.destinationViewController as? UIViewControllerSubclassChangeToYourDestinationClass {
vc.popoverPresentationController?.barButtonItem = yourBarButtonItem
}
}
As for the second question, iPhones are allowed to present popovers, that changed in iOS 8. The question for your app is whether or not it makes sense to so-do, given the constrained screen size. Normally they would present as a full-page on iPhone, but you can conform your source view controller to UIAdaptivePresentationControllerDelegate, then override the following method so a modal presentation doesn't occur:
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return .None
}
If you implement that adaptive presentation delegate, then you'd also need to update -prepareForSegue: such that the destination view controller ("vc", above) knows the current class is its adaptive presentation delegate:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let vc = segue.destinationViewController as? UIViewControllerSubclassChangeToYourDestinationClass {
vc.popoverPresentationController?.barButtonItem = yourBarButtonItem
vc.popoverPresentationController?.delegate = self
}
}
There's a WWDC 2014 talk about new view controller adaptive styles, the concept is explained in there. In that video there's a comment about setting the delegate *after* presenting the new view controller, which isn't now the case, you set the delegate before presenting, but I think it would be worth an hour or so to give that video a watch through to learn more about these techniques.
Hope this helps.