gpt4 book ai didi

ios - 缺少 UIPopoverController 的 PopoverBackroundViewClass 属性

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:17:07 39 4
gpt4 key购买 nike

我正在使用最新的 Monotouch 5.2.4。作为我开发的一部分,我正在尝试更改 Popover Controller 的背景边框。根据苹果文档,这可以使用从 UIPopoverBackgroundView 类继承的自定义类来管理。

所以我创建了如下类

public class MyPopoverBackground : UIPopoverBackgroundView
{
public MyPopoverBackground ()
{
UIImageView imgBackground = new UIImageView();
UIImage img = UIImage.FromFile(@"SupportData/Popbg.png");
img.StretchableImage(18,10);
imgBackground.Image = img;
this.AddSubview(imgBackground);
}
}

创建此类后,我尝试将此 View 与 View Controller 中的 Popup 对象相关联。定义如下

UIPopoverController popup = new UIPopoverController(searchPage);
popup.popOverBackroundViewClass = new MyPopoverBackground(); //This line throws compilation error

上面代码的最后一行,赋值发生时抛出编译错误(“不包含对..”的定义)。

这是什么意思?这在 Monotouch 中不受支持吗(我在网上看到很多示例,似乎在 Objective-C 中受支持)?或者我遗漏了什么。

感谢您的帮助。

最佳答案

抓得好!它看起来像是 popoverBackgroundViewClass 的绑定(bind)(iOS5 中的新功能)目前在 MonoTouch 中缺失。

我会考虑实现它。如果您想在 http://bugzilla.xamarin.com 填写错误报告完成后您会收到通知(只需一个带有此问题链接的快速错误报告就足够了)。我还应该能够为您提供修补程序或解决方法。

更新

在 MonoTouch 5.3+(一旦发布)中,您将能够执行如下操作:

popoverController.PopoverBackgroundViewType = typeof (MyPopoverBackgroundView);

请注意,您不能创建自己的实例,因为它需要从 native 端完成(因此您只告诉 UIPopoverController 要创建的类型)。

您还需要遵循 UIPopoverBackgroundView 的所有要求,这意味着导出所需的选择器(这比简单继承要复杂一些,因为它也需要 static 方法) .例如

    class MyPopoverBackgroundView : UIPopoverBackgroundView {

public MyPopoverBackgroundView (IntPtr handle) : base (handle)
{
ArrowOffset = 5f;
ArrowDirection = UIPopoverArrowDirection.Up;
}

public override float ArrowOffset { get; set; }

public override UIPopoverArrowDirection ArrowDirection { get; set; }

[Export ("arrowHeight")]
static new float GetArrowHeight ()
{
return 10f;
}

[Export ("arrowBase")]
static new float GetArrowBase ()
{
return 10f;
}

[Export ("contentViewInsets")]
static new UIEdgeInsets GetContentViewInsets ()
{
return UIEdgeInsets.Zero;
}
}

关于ios - 缺少 UIPopoverController 的 PopoverBackroundViewClass 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9311914/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com