Nevermind, I've solved my problem.
In ViewController.m I've added a _draggedTile
ivar and set it in touchesBegan
by using the following method to find the touched tile:
- (SmallTile*) findTileAtPoint:(CGPoint)point withEvent:(UIEvent*)event
{
NSArray* children = [self.view.subviews arrayByAddingObjectsFromArray:_contentView.subviews];
for (UIView* child in children) {
CGPoint localPoint = [child convertPoint:point fromView:self.view];
if ([child isKindOfClass:[SmallTile class]] &&
[child pointInside:localPoint withEvent:event]) {
return (SmallTile*)child;
}
}
return nil;
}
And in touchedMoved
, touchesEnded
, touchesCancelled
I just use that ivar (initially I was using the above findTileAtPoint:withEvent:
method there as well, but sometimes the touch wouldn't be exactly over the dragged tile and the movement was jerky or cancelled).