从滚动视图中拖动图像

发布于 2024-09-15 02:05:56 字数 621 浏览 5 评论 0原文

这让我发疯,已经用了很多年了,仍然可以让它做我想做的事!

我的视图是这样设置的:

RootViewController 包含 (UIView)flipView

FlipView 包含 (UiView)firstView FirstView

包含一个滚动视图和大量图像视图

Scrollview 包含一系列自定义图像视图

我可以左右拖动自定义图像视图,无论我拖动哪个它出现在滚动视图中所有其他自定义 imageView 之上,因为自定义 UIImageViews attemptsBegan 方法中的这一行:

[[self superview] BringSubviewToFront:self];

伟大的!但是......

虽然我可以垂直拖动并且自定义 imageView 根据需要离开滚动视图的边界,但我无法让它出现在第一个视图上的任何图像视图之上?

我还发现,如果我在第一次触摸要拖动的图像视图时显示 point.y 值,它会显示 24,当我开始向上拖动以将其从滚动视图中取出时,它会变为 26,然后保持在该值,即使我可以将其一直拖动到屏幕顶部,位于所有其他图像视图的后面吗?

我显然错过了明显的出血……显然……请帮忙?

谢谢

This is driving me bonkers, have been on it ages and still can get the thing to do what I want!

My view is set out like this:

RootViewController contains (UIView)flipView

FlipView contains (UiView)firstView

FirstView contains a scrollview and a load of imageviews

Scrollview contains a series of custom imageViews

I can drag the custom imageViews left and right and whichever one I drag it appears above all other custom imageViews in the scrollview because of this line in the custom UIImageViews touchesBegan method:

[[self superview] bringSubviewToFront:self];

Great! But.....

Although I can drag vertically and the custom imageView leaves the bounds of the scrollview as required I cannot get it to appear above any of the imageviews that are on firstview?

I also have found that if I display the point.y value when I first touch the imageview to be dragged it shows 24 as I start to drag up to take it off the scrollview it goes to 26 and then stays at that value even though I can drag it all the way to the top of the screen, behind all the other imageviews?

I have obviously missed the bleeding obvious....obviously....help please?

Thanks

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

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

发布评论

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

评论(1

太阳哥哥 2024-09-22 02:05:56

BringSubviewToFront:仅在该视图中工作,即您的滚动视图需要位于所有其他图像视图的前面,否则它们将覆盖您的滚动视图。
如果您想从滚动视图中删除图像,可能值得将其删除并在拖动时将其直接添加到第一个视图的所有内容之上。

bringSubviewToFront: will only work within that view, i.e. your scrollview needs to be in front of all those other imageViews, or they will cover your scrollview.
If you want to remove the image from the scrollview, it might be worth removing it and adding it on top of everything directly to your firstView while dragging.

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