如何检查 UIScrollView 中某一帧是否存在子视图?

发布于 2024-08-17 16:41:14 字数 141 浏览 4 评论 0原文

我有一个 UIScrollView,其 contentSize 约为 5000*5000。我有子视图的坐标和框架。我想检查 UIScrollView 中的确切位置是否存在子视图。

如果没有。我将添加一个新的子视图,如果是,我将不会添加。有人可以帮忙吗?

I have a UIScrollView with a big contentSize of around 5000*5000. I have the coordinates and the frame of a subview. I want to check whether a subview exists at that exact position in UIScrollView.

If no. I will add a new subView and if Yes I will not add. Can anyone help?

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

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

发布评论

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

评论(2

在风中等你 2024-08-24 16:41:14
[theScrollView hitTest:thePoint withEvent:nil];

将返回此时最深的 CALayer。如果您确定该点位于 UIScrollView 内,则如果 hitTest: 返回 UIScrollView 的 CALayer,则该点不存在子视图。

[theScrollView hitTest:thePoint withEvent:nil];

will return the deepest CALayer at that point. If you are sure the point is within the UIScrollView, then if hitTest: returns the UIScrollView's CALayer, no subview exists at that point.

メ斷腸人バ 2024-08-24 16:41:14
 [theScrollView hitTest:thePoint withEvent:nil];
 [theScrollView hitTest:thePoint withEvent:nil];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文