Does anyone know why this code won't work. Just added a popovercontroller to the hello world example from xamarin. I always get a unhandled exception but there is no additional information in the output.
public class MyViewController : UIViewController
{
UIButton button;
int numClicks = 0;
float buttonWidth = 200;
float buttonHeight = 50;
UIPopoverController popover;
public MyViewController()
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.Frame = UIScreen.MainScreen.Bounds;
View.BackgroundColor = UIColor.White;
View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
button = UIButton.FromType(UIButtonType.RoundedRect);
button.Frame = new RectangleF(
View.Frame.Width / 2 - buttonWidth / 2,
View.Frame.Height / 2 - buttonHeight / 2,
buttonWidth,
buttonHeight);
button.SetTitle("Click me", UIControlState.Normal);
button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin |
UIViewAutoresizing.FlexibleBottomMargin;
var content = new UIViewController();
popover = new UIPopoverController(content);
popover.SetPopoverContentSize(new SizeF(80, 80), true);
button.TouchUpInside += (object sender, EventArgs e) =>
{
popover.PresentFromRect(new RectangleF(80, 80, 80, 80), View, UIPopoverArrowDirection.Left, true);
};
View.AddSubview(button);
}
}
Thanks for any respond.