iphone - Checking to see if point in child view is in parent view -


i have following set-up:

enter image description here

where light blue view, let's call parentview, has rectangular subview (the purple view) called childview. user can use pan touches rotate , stretch childview putting finger on point exhibited red dot , pushing or pulling it.

it's possible childview scaled small enough after user finished touches, point denoted red dot inside of parentview.

my goal create method can detect if red point in parentview or not. i've written following code:

cgpoint childviewredpoint = cgpointmake(self.bounds.size.width, self.bounds.size.height / 2); cgpoint rotatedchildviewredpoint = cgpointapplyaffinetransform(childviewredpoint, cgaffinetransformmakerotation(self.rotateangle)); cgpoint convertedchildviewredpoint = [self convertpoint:rotatedchildviewredpoint toview:self.superview];  if (cgrectcontainspoint(self.superview.bounds, convertedchildviewredpoint)) {     return yes; } else {     return no; } 

first find red point defined within childview, rotate amount view has been rotated, convert in parentviews coordinates.

the points i'm getting don't seem make sense , isn't working. wondering if knows i'm going wrong here? not taking parentviews superview account?

i not 100% sure, think convertpoint: takes rotation (or other transformation) account, need:

cgpoint childviewredpoint = cgpointmake(self.bounds.size.width, self.bounds.size.height / 2); cgpoint convertedchildviewredpoint = [self convertpoint:childviewredpoint toview:self.superview];  if (cgrectcontainspoint(self.superview.bounds, convertedchildviewredpoint)) ... 

Comments