KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to understand the functionalities of these methods. Could you provide me with a simple use case to understand their semantics? From the documentation, for example, convertPoint:fromView: method is described as follows: Converts a point from the coordinate system of a given view to that of the receiver. What does the coordinate system mean? What about the receiver ? For example, does it make sense using convertPoint:fromView: like the following? CGPoint p = [view1 convertPoint:view1.center fromView:view1]; Using NSLog utility, I've verified that p value coincides with view1 's center. Thank you in advance. EDIT: For those interested, I've created a simple code snippet to understand these methods. UIView* view1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 150, 200)]; view1.backgroundColor = [UIColor redColor]; NSLog(@"view1 frame: %@", NSStringFromCGRect(view1.frame)); NSLog(@"view1 center: %@", NSStringFromCGPoint(view1.center)); CGPoint originInWindowCoordinates = [self.window convertPoint:view1.bounds.origin fromView:view1]; NSLog(@"convertPoint:fromView: %@", NSStringFromCGPoint(originInWindowCoordinates)); CGPoint originInView1Coordinates = [self.window convertPoint:view1.frame.origin toView:view1]; NSLog(@"convertPoint:toView: %@", NSStringFromCGPoint(originInView1Coordinates)); In both cases self.window is the receiver. But there is a difference. In the first case the convertPoint parameter is expressed in view1 coordinates. The output is the following: convertPoint:fromView: {100, 100} In the second one, instead, convertPoint is expresse
Tags (comma-separated)
Save Edits
Cancel