I wish to drag a UIImage on to one of several UIButtons and have it repositioned based on which button I drag it to.
The problem I\'ve ran in to is that UITouch only
It is very easy to detect your finally touched view, try this code
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint location = [[touches anyObject] locationInView:self.view];
CGRect fingerRect = CGRectMake(location.x-5, location.y-5, 10, 10);
for(UIView *view in self.view.subviews){
CGRect subviewFrame = view.frame;
if(CGRectIntersectsRect(fingerRect, subviewFrame)){
//we found the finally touched view
NSLog(@"Yeah !, i found it %@",view);
}
}
}