I am working on my first iOS application and launched the first error, I could not find a good answer.
Problem: I have a custom UIGestureRecognizer and it is all connected correctly, and I can run the code for every click in @selector after recognition. It was good for most things, but a little too much for others.
My goal: to make a timer that starts at a given interval to start the logic, and be able to cancel it at the time of canceling orders.
Why I ask here: there are many opportunities for solutions, but none of them stand out best. So far itβs like
performSelector (and some variations of this)NSThreadNSTimerNSDate- Operation Queues
- I think I found others ...
Of all the studies, some form of threading seems like a route for transition, but I'm at a loss what works best for this situation.
Implementation example: a NSPoint is taken every 0.10 seconds, and the distance between the previous and current point is taken. [Taking the distance between each point yielded very dirty results].
Relevant Code:
- (void)viewDidLoad { CUIVerticalSwipeHold *vSwipe = [[CUIVerticalSwipeHold alloc] initWithTarget:self action:@selector(touchHoldMove:)]; [self.view addGestureRecognizer:vSwipe]; [vSwipe requireGestureRecognizerToFail:doubleTap]; } ... - (IBAction)touchHoldMove:(UIGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { } if (sender.state == UIGestureRecognizerStateBegan) { }
source share