如何检查 UIScrollView 中某一帧是否存在子视图?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将返回此时最深的 CALayer。如果您确定该点位于 UIScrollView 内,则如果 hitTest: 返回 UIScrollView 的 CALayer,则该点不存在子视图。
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.