【问题标题】:how to get the center point of a scrollview subview relative to scrollview superview?如何获得相对于滚动视图超级视图的滚动视图子视图的中心点?
【发布时间】:2013-03-19 04:21:11
【问题描述】:

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

scrollView的superView叫做pView,比如白色view1相对于pView的中心点是(10,10),view6的中心点是(496,10),我滚动这个视图后如下:

视点6的中心点是(10,10),但是不知道怎么弄。

也许我应该使用像

这样的代码
        CGPoint centerPoint = [view6 convertPoint:view6.center toView:pView];

但我没有得到正确的观点

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    view6.center 在 vi​​ew6 的父视图(即 UIScrollView)的坐标系中。试试

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多