Objective c 查找子视图的实际来源iOS Sdk

Objective c 查找子视图的实际来源iOS Sdk,objective-c,xcode,Objective C,Xcode,如果我将进度条放在UIScrollView的外面,我会得到一些x&y轴(如(110250)),如果我将进度条放在UIScrollView中,我会得到不同的x&y轴(如(9100)) 我的要求是我必须将进度条放在UIScrollView中,但我想知道进度条在UIScrollView之外的x&y轴 i、 我的进度条原点必须根据UIView而不是Scrollview进行计算 请给我解决方案。UIView可以将矩形从一个坐标空间转换为另一个坐标空间,只要它们有一个共同的父视图(甚至窗口)。例如: [sc

如果我将进度条放在UIScrollView的外面,我会得到一些x&y轴(如(110250)),如果我将进度条放在UIScrollView中,我会得到不同的x&y轴(如(9100))

我的要求是我必须将进度条放在UIScrollView中,但我想知道进度条在UIScrollView之外的x&y轴

i、 我的进度条原点必须根据UIView而不是Scrollview进行计算


请给我解决方案。

UIView可以将矩形从一个坐标空间转换为另一个坐标空间,只要它们有一个共同的父视图(甚至窗口)。例如:

[scrollview convertRect:subview.frame toView:someOtherView];  //scrollView converts the frame of subView.frame to the coordinate system of someOtherView
有几种方法可以将点或矩形从另一个视图转换或转换到另一个视图:

[superView convertRect:anotherView.frame fromView:anotherView.superView]; //Will give you the rect of anotherView.frame in superView coordinate system.
注意,rect可以是任何东西(不需要是特定视图的框架)。该方法所做的只是从一个坐标空间转换到另一个坐标空间

此外,要在屏幕(或主窗口)上查找视图的坐标,可以将“toView:”设置为零:


UIView可以将矩形从一个坐标空间转换为另一个坐标空间,只要它们具有公共父视图(甚至窗口)。例如:

[scrollview convertRect:subview.frame toView:someOtherView];  //scrollView converts the frame of subView.frame to the coordinate system of someOtherView
有几种方法可以将点或矩形从另一个视图转换或转换到另一个视图:

[superView convertRect:anotherView.frame fromView:anotherView.superView]; //Will give you the rect of anotherView.frame in superView coordinate system.
注意,rect可以是任何东西(不需要是特定视图的框架)。该方法所做的只是从一个坐标空间转换到另一个坐标空间

此外,要在屏幕(或主窗口)上查找视图的坐标,可以将“toView:”设置为零:


这两种UIView方法应该可以帮助您:

– convertPoint:toView:
– convertPoint:fromView:

这两种UIView方法应该可以帮助您:

– convertPoint:toView:
– convertPoint:fromView: