【发布时间】:2016-05-09 14:33:07
【问题描述】:
我在使用 Popover 的 Xamarin iOS 实现时遇到问题。
就我现在而言,它们可以通过 Apple 文档 (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPopoverPresentationController_class/) 中描述的新 UIPopoverPresentationController 类获得
我的代码是这样的:
public partial class PopoverSettings : UIViewController
{
public PopoverSettings () //: base ("PopoverSettings", null)
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
View.Frame = new CoreGraphics.CGRect(0,0,100,100);
this.PreferredContentSize = new CoreGraphics.CGSize (10, 10);
View.BackgroundColor = UIColor.Red;
}
}
我尝试从
创建它var myPop = new PopoverSettings();
myPop.ModalInPopover = true;
myPop.ModalPresentationStyle = UIModalPresentationStyle.Popover;
var pc = (UIPopoverPresentationController)myPop.PresentationController;
pc.SourceView = navigation;
pc.SourceRect = new CGRect(0,0,100,100);
this.PresentViewController(myPop, true, null);
结果有效,但我得到的是全屏视图控制器,而不是“弹出框”组件!
有人知道为什么会这样吗?谢谢!
【问题讨论】:
-
您是在 iPad 还是 iPhone 上尝试这个?看看这个:stackoverflow.com/questions/25319179/…
-
是的,但该解决方案包括 .NET 中不支持的多重继承(来自 UIViewController 和 UIPopoverPresentationControllerDelegate)
-
要绕过这个限制,您可以实现
IUIPopoverControllerDelegate并重写适当的委托方法。 developer.xamarin.com/api/type/… -
即使尝试实现 IUIPopoverPresentationControllerDelegate 它也不起作用。我可能感兴趣的每个属性都是“只读”的,如果我设置 Controller.PopoverPresentationController.Delegate = this,则该事件不是触发事件
-
上面第二个代码块中的“导航”是什么?
标签: xamarin.ios modal-dialog uipopovercontroller uipopover