将 UIView 从 UIPopOverController 内的 UIScrollView 拖放到主 UIViewController?

发布于 2024-12-08 17:36:45 字数 724 浏览 5 评论 0原文

好吧,我很难让它正常工作。如果有人成功地做到了这一点,并且愿意分享代码,我将永远感激你!

这就是我想要做的...

我有一个主 ViewController,我从中创建了 UIPopoverController。此 PopOverController 包含一个包含 UIImageViews 的视图。这些 UIImageView 是在 PopOverController 的 viewDidLoad 方法中以编程方式创建的。我试图让 UIView 从 PopOverController 内的 popoverView 平移到呈现 PopOverController 的主 ViewController。

我让它工作起来......

当 UIImageView 被平移时,我创建一个 UIWindow 并将该 UIImageView 作为子视图添加到新窗口中。然后,我可以将 UIImageView 平移到 PopOverController 之外,并在手势结束状态下,从我创建的窗口中删除 UIImageView 并将其添加到 keyWindow 中。但是,当我这样做时, UIImageView 逆时针旋转,并且该视图/窗口的平移不会在手指下开始。我也不确定为什么会发生这种情况。我确信这两个问题都是我所缺少的同一主要问题的一部分。

我做了一个单独的项目,只包含我无法正常工作的部分。如果您感到无聊并愿意接受让它工作的挑战..这里有一个链接来下载项目。

Okay, I'm having trouble getting this to work right. If anyone has successfully done this, and would be willing to share the code, I'd be forever in your debt!

Here's what I'm trying to do...

I have a main ViewController that I create my UIPopoverController from. This PopOverController contains a View that contains UIImageViews. These UIImageViews are programatically created in the viewDidLoad method of my PopOverController. I'm trying to get the UIView to pan from the popoverView within my PopOverController to the main ViewController that presents the PopOverController.

I got it to work kind of...

When a UIImageView is panned, I create a UIWindow and add that UIImageView as a subview to the new window. I can then pan the UIImageView outside the PopOverController, and in the Gesture ended state, remove the UIImageView from the window I created and add it to the keyWindow. However, when I do this, the UIImageView is rotated counter clockwise, and the panning of that view/window does not start under the finger. I'm not sure why that's happening either. I'm sure both issues are part of the same main thing I'm missing.

I made a separate project with just the part I can't get to work right. If you're bored and feel up to the challenge in getting it to work.. Here is a link to download the project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2024-12-15 17:36:45

我还没有完全解决你的问题,但我查看了该项目,并解决了(在你的设置中)旋转的 UIImageView 最初没有出现在正确位置的问题。当您转换矩形时,您需要使用该片段的超级视图,即(popupcontroller.m 中的第 72 行)

newPiece.frame = [piece.superview convertRect:piece.frame toView:dragAndDropWindow]; 

希望这会有所帮助。

I haven't completely solved your problem, but I had a look at the project and I solved the problem (in your setting) of not having the rotated UIImageView initially appear at the correct position. You need to use the superview of the piece when you convert the rect, i.e., (line 72 in popupcontroller.m)

newPiece.frame = [piece.superview convertRect:piece.frame toView:dragAndDropWindow]; 

Hope this helps a bit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文