2014-02-17 4 views
0

에서 개체의 CGPoint를 determinie 방법 :아이폰 OS : UIView의에서이 같은 객체의 CGpoint를 얻을 수 있지만있는 ScrollView

x = self.object.frame.origin.x; 
y = self.object.frame.origin.y; 

을하지만 내 개체가있는 ScrollView에있을 때이 코드를 사용할 때, 나는있어 동일한 x와 y는 UIView에 있습니다. 그래서 scrollView에있을 때 오브젝트 CGPoint를 어떻게 결정할 수 있을까요?

+0

가능한 중복 (http://stackoverflow.com/ :이있는 UIScrollView 적용 스크롤의 금액으로, 포인트의 상대 위치를 조정합니다 질문/15883305/parent-uiview 내에서 상대 위치를 사용하는 변환 포인트 사용) – Cyrille

답변

1

의 사용해야합니다. [부모의 UIView 내부의 상대 위치를 얻을 수 convertPoint 사용]을의

x = self.object.bounds.origin.x + self.yourScrollView.contentOffset.x; 
y = self.object.bounds.origin.y + self.yourScrollView.contentOffset.y; 
0

당신은있는 UIScrollView의 contentOffset를 추가 bounds 대신 frame

2
CGPoint pointOfSubviewAccoringToSelfView = [self.view convertPoint:self.subview.frame.origin fromView:self.scrollView];