如何在UIPopoverController之上添加视图 [英] How to add a view on top of a UIPopoverController

查看:105
本文介绍了如何在UIPopoverController之上添加视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有抽屉表格的iPad应用程序,显示在popover中。用户可以轻敲并保持抽屉中的项目以将该项目拖出其中并进入我的主视图。那部分工作正常;不幸的是,被拖动的视图出现在弹出窗口下方,并且太小而不能被看到,直到它从它下方被拖出。如果我将视图作为视图控制器的子视图添加到弹出窗口中,它会被弹出框架剪切,因为我无法访问 UIPopoverController 的观点,我无法禁用其图层的 masksToBounds - 这无论如何都不是一个好主意。我怀疑我可以使用额外的 UIWindow 并使用高 windowLevel 值来强制拖动的视图出现在popover,但这似乎有点矫枉过正。有更好的解决方案吗?

I've got an iPad app with a "drawer" table displayed in a popover. The user can tap-and-hold on an item in the drawer to drag that item out of it and into my main view. That part works fine; unfortunately, the view being dragged appears under the popover, and is too small to be visible until it's dragged out from underneath it. If I add the view as a subview of the view controller in the popover, it gets clipped by the popover's frame, and as I can't access the UIPopoverController's view, I can't disable its layer's masksToBounds—and that probably wouldn't be a great idea anyway. I suspect that I could use an additional UIWindow with a high windowLevel value to force the dragged view to appear on top of the popover, but this seems like overkill. Is there a better solution?

推荐答案

知道了。 UIWindow 运行正常。代码:

Got it. UIWindow works fine. Code:

// when drag starts
draggingView = [[UIWindow alloc] initWithFrame:CGRectMake(0,0,100,100)];
draggingView.windowLevel = UIWindowLevelAlert;
draggingView.center = [gestureRecognizer locationInView:self.view.window];
[draggingView makeKeyAndVisible];

// when drag ends
[draggingView release];
draggingView = nil;

这篇关于如何在UIPopoverController之上添加视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆