Reputation: 533
i have multiple buttons and i am adding them into the UIView. I have added TouchDown/TouchUp events to all the buttons. Upto this, everything is pretty simple and works perfect
But now my requirement is, i want to swipe on the view and while swiping, i want to detect the same TouchDown/TouchUp events under the swipe. (say on button's touchdown, i will change highlight image of button and on touchup it get back to its normal image)
Is it possible?
How could i achieve it?
Upvotes: 0
Views: 789
Reputation: 11607
Do you specifically need the swipe gesture?
There is this method which detects when your fingers slide across UIView:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
Maybe you can create a class that inherits from UIButton and add the touchesMoved method:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// psuedo code
[self setBackgroundImageForControlState:@"file.png"];
}
Then in the touches Ended method, you can swap a different image in:
// when finger is raised off the button
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// psuedo code
[self setBackgroundImageForControlState:@"file.png"];
}
Upvotes: 2
Reputation: 6924
Maybe you should hadle events like UIControlEventTouchDragEnter
and UIControlEventTouchDragExit
?
Not sure, but it seems to be a solution.
Upvotes: 1