While my user is dragging his finger while holding down a UIButton, can I get the touch location for the finger at that point? If I can't do this it seems that I could probably create a UIImageView and give it button qualities. After this I would implement the touches began, moved, ended methods.
These methods; however, do not run while a UIButton has been touched.
The reason I need this is because I wanted to find out the direction of a touch drag outside movement, and for various other reasons too, but if this is impossible I will have to create UIImageViews I think.
Also, I do not subclass UIButton, I am too much beginner to take on apples clusters.
you should following this:
[myButton addTarget:self action:@selector(dragHandler:withEvent:) forControlEvents:UIControlEventTouchDragInside];
[myButton addTarget:self action:@selector(dragHandler:withEvent:) forControlEvents:UIControlEventTouchDragOutside];
-(void)dragHandler:(UIButton *)sender withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
NSLog(@"touchInfo:%@", NSStringFromCGPoint([touch locationInView:self.view]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With