How to convert SubView's Frame Coordinate System to Self View's Coordinate System

Viewed 32656

I create programmatically one scrollView and some buttons inside there. When I click the any button have to show a popover.

My button's origin in self.view is like (100,11) and inside scrollView (9,11) and scrowView is in somewhere in self.view. The popover shows in (9,11) but right one would be (100,11). I try use convert without success.

-(IBAction)showPopover:(id)sender{
//... implemented popover above

//Wrong Origin:
NSLog(@"wrong x:%f y:%f",[sender frame].origin.x, [sender frame].origin.y);

//Transform to correct
CGRect frame = [self.view convertRect:[sender frame] toView:nil];

//Shoulf be right, but is not...
NSLog(@"new x:%f y:%f",frame.origin.x, frame.origin.y);
}

Anyone cam help me?

2 Answers
Related