- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用最新的 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/
如上所述,在 iOS8 中,[UIPopoverController presentPopoverFromRect] 不再适用于 [UIApplication sharedApplication].k
我有一个 UISearchBar。当用户触摸 UISearchBar 时,会显示一个包含结果的 UITableView 的 UIPopoverController。当用户输入时,结果就会出现。 我希望
我正在尝试创建一个如上所示的弹出窗口。 它可以是一个按钮或只有一个项目的 TableViewController。 我查看了很多教程,但它们似乎都比必要的复杂得多。 有没有办法在不创建新的 ViewC
有谁知道是否可以在 iPad 上为 UIPopOverController 设置透明背景? 我想在弹出框内放置一个半透明 View (因此希望弹出框本身具有透明背景)。 我认为这是不可能的……但我很想
如何“执行选择器”到uipopovercontroller的parentviewcontroller? 我有从uiviewcontroller中解放出来的uipopovercontroller,这个u
希望有办法做到这一点。希望只显示 View 周围的边框,顶部没有 40px 标题栏。可能吗? 最佳答案 已回答...我正在使用导航 Controller 初始化它。一旦我删除了它,我就没有得到标题栏。
我有一个通用应用程序。在 iPad 上,当按下注释图钉时,它会显示标注气泡。当我按下关闭按钮时,它会加载一个带有详细 View 的 uipopovercontroller。我想知道的是如何加载 uip
我想知道如何制作一个没有箭头的 UIPopoverController事实上我想模拟这样的事情: 看看 没有箭头 有一个标题以某种方式位于 UIPopoverController 的扩展顶部边框内部,
我有一个显示表格的 UIPopoverController。我使用 PresentFromBarButtonItem 方法。 我怎样才能给弹出窗口显示一个标题,UISpliter 做了多少列表? 最佳
我有一个问题,this question 的回答最多。 . 但是,我的任务略有不同。我想将 UIImageViews 从 UIPopover Controller 拖放到另一个 UIView,但弹出框
我正在以这种方式创建一个弹出框: popoverController = [[UIPopoverController alloc]initWithContentViewController:brows
我有一个 UIPopoverController由 TableView 组成。这个弹出式 Controller 显示得很好,我已经设置了委托(delegate) didSelectRowAtIndex
是否可以从第一个弹出窗口 UIButton 单击打开另一个 uipopovercontroller?如果是,那我该怎么做? 现在我正在使用给定的代码从 UIBarButtonItem 打开一个弹出窗口
我正在窗口内切换 View 。方向有时会混淆。 在其中一个窗口中,当我尝试显示应附加到工具栏按钮的弹出窗口时,它显示在屏幕上的位置。如果我物理地改变设备的方向,弹出窗口会在正确的位置重绘。如果我再次切
iOS 9 中 PopoverController 的正确代码是什么?在任何地方都可以找到此代码的正确代码? @IBAction func share(发送者:UIBarButtonItem){
我有一个普通的 UIPopoverController,它是这样制作的: -(IBAction)btKBIs_click:(id)sender { if(kbiPopOver != NULL)
我有一个按钮,当按下它时会显示一个 View Controller ,这是一个通用应用程序。 在 iPhone 上, View Controller 被推送到导航堆栈上。在 iPad 上,它显示在弹出
在 iOS 7 中,UIPopoverControllers 具有视差效果(前景悬停在背景之上)。 这在处于纵向模式的 UISplitViewController 中尤其难看。 线条不在同一水平面上。
我知道 UIPopOverController 可以提供标准下拉菜单,但我很好奇它是否可以提供动态下拉菜单。 动态下拉菜单将更进一步,单击列表中的任何项目都可以展开更多选项或执行某些其他操作,类似于文
我发现在呈现 UIPopoverController 时,并非呈现 View 中的所有控件都被禁用。具体来说,导航栏按钮(例如“后退”)仍然可选。我认为这是一个缺陷 - 它允许弹出窗口保留在屏幕上,而
我是一名优秀的程序员,十分优秀!