Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何获取相对于scrollview superview的scrollview子视图的中心点?_Ios_Objective C - Fatal编程技术网

Ios 如何获取相对于scrollview superview的scrollview子视图的中心点?

Ios 如何获取相对于scrollview superview的scrollview子视图的中心点?,ios,objective-c,Ios,Objective C,我有一个scollView(下图中显示的蓝色视图),其中包含20个子视图(白色视图) scrollView的superView称为pView,例如,白色视图1相对于pView的中心点为(10,10),而view6的中心点为(496,10),在我滚动该视图后,如下所示: 中心视点6是(10,10),但我不知道如何得到它 也许我应该使用这样的代码 CGPoint centerPoint = [view6 convertPoint:view6.center toView:pView]

我有一个scollView(下图中显示的蓝色视图),其中包含20个子视图(白色视图)

scrollView的superView称为pView,例如,白色视图1相对于pView的中心点为(10,10),而view6的中心点为(496,10),在我滚动该视图后,如下所示:

中心视点6是(10,10),但我不知道如何得到它

也许我应该使用这样的代码

        CGPoint centerPoint = [view6 convertPoint:view6.center toView:pView];

但是我没有得到正确的点,view6.center位于view6的superview(即UIScrollView)的坐标系中。试一试

CGPoint centerPoint=[scrollView-convertPoint:view6.center-to-view:pView]