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?
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"];
}
Maybe you should hadle events like UIControlEventTouchDragEnter
and UIControlEventTouchDragExit
? Not sure, but it seems to be a solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.