I am having difficulty presenting a Popover with UIPopoverPresentationController
, following what can I find from the internet, including this and this. Nothing has helped. Here's a test app I created:
ViewController.cs
public override void ViewDidLoad()
{
...
var popupView = new UIImageView(new CGRect(0, 0, 200, 200))
{
Image = UIImage.FromBundle("Menu")
};
_menuController = new UIViewController
{
ModalPresentationStyle = UIModalPresentationStyle.Popover,
View = popupView
};
_presentationController = new UIPopoverPresentationController(_menuController, this)
{
SourceView = View,
SourceRect = new CGRect(50, 50, 300, 300),
};
}
And I invoke on button press with:
PresentViewController(_menuController, true, null);
I get this exception when the presentation style is Popover
:
UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs.