So I have 2 UIViews witch can draw a bezierpath and then returns the path. Then I need to check if the path contains a point I do this with help of [path containsPoint:currentObject.position]and it works for one of the views but not the other.
One view is on the top half of the iPhone and the other view is on the bottom half. The one on the bottom don’t work.
I tried to switch the views, and then it was the same problem, the bottom one doesn’t work.
Here is some code:
in mainviewcontroller:
-(void)didEndPath:(UIBezierPath *)path DrawView:(DrawView *)draw {
if ([path containsPoint:currentObject.position]) {
//do stuff
}
}
and in drawview touches ended I do this:
[self.delegate didEndPath:currentPath DrawView:self];
Why doesn’t it work, can it be that the view has another origin then self.view? How do I fix it?
EDIT:
Okey, so I found the problem but not the solution.
If I change the touch methods in my UIView from this:
startPoint = [touch locationInView:self];to this startPoint = [touch locationInView:self.superview];then it reads the touches correctly but my path won’t draw. Still the problem is only with the bottom uiview. So how can I change so it returns a path with touches location in superview, but draws it within it self?
I solved the problem by making 2 paths. One with points from superview and one without. It works but i don’t know if its the best solution.