I've applied this stackoverflow entry so that I can detect the touch as it moves from one view to the other.
The subviews really detect the touch. However, I'm doing something more. I need the view that detected the touch to be removed from it's parent view and add new views to the parent view. So, I have something like this:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.contentView];
for (UIView *view in self.contentView.subviews)
{
if ([view isKindOfClass:[MyCustomView class]] &&
CGRectContainsPoint(view.frame, touchLocation))
{
[view removeFromSuperview];
UIView *aNewView = [[[UIView alloc] initWithFrame:someFrame] autorelease];
[self.contentView addSubview:aNewView];
}
}
}
After passing through the if-statement, the app fails to respond to the touch move. What do you think is the problem? Was it caused by this: [view removeFromSuperview]
?