Reputation: 5
If I have a view inside another view, than its x,y values are relevant to its parent view.
I would like to know its x y position relative to the whole screen window-
that means 320 X 480 iphone screen window
The top left corner is 0,0 of course.
What is the way for getting its "True" x ,y values?
Thanks.
Upvotes: 0
Views: 319
Reputation: 19789
Use convertPoint:toView:, where the to view is the window property - although that isn't necessarily the screen, it usually will be.
Upvotes: 2
Reputation: 6095
Pseudo code as not on my mac and can't remember the exact structure of the objects, but something along the lines of:
x = self.parentView.frame.x + self.frame.x;
y = self.parentView.frame.y + self.frame.y;
You could easily extend this to use a loop or recursion if the views are going to be more than one deep.
Upvotes: 0