Show/hide UIToolbar, “match finger movement”, precisely as in for example iOS7 Safari

There is no open-source that does this, but I don’t see it as that difficult to implement. It may be somewhat more difficult to have the exact 1:1 behavior as Safari, but it can still be done. MobileSafar can be attached to in the debugger and, using breakpoints and the Objective C runtime, debugged and … Read more

Combining a UILongPressGestureRecognizer with a UIPanGestureRecognizer

actually, you don’t have to combine gesture recognizers – you can do this solely with UILongPressGestureRecognizer… You enter StateBegan once your touch(es) have stayed within ‘allowableMovement’ for ‘minimumPressDuration’. You stay in your continuous longPressGesture as long as you don’t lift any of your fingers – so you can start moving your fingers and track the … Read more

How to detect Swipe Gesture in iOS?

If You know how it works, but still need a quick example, here it is! (it will become handy at least for me, when I will need copy-paste example, without trying remembering it) UISwipeGestureRecognizer *mSwipeUpRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething)]; [mSwipeUpRecognizer setDirection:(UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight)]; [[self view] addGestureRecognizer:mSwipeUpRecognizer]; and in .h file … Read more

Simultaneous gesture recognizers in Iphone SDK

It was really easy: At first we should create class, that implements UIGestureRecognizerDelegate protocol: @interface MyGestureDelegate : NSObject <UIGestureRecognizerDelegate> @implementation MyGestureDelegate – (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ return YES; } – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ return YES; } – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ return YES; } And use it like this: UISwipeGestureRecognizer *swipeGestureLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGestureLeft:)]; … Read more

How do I implement the UITapGestureRecognizer into my application

This is a step by step guide on how to implement gesture recognizers in your class: Conform your class to UIGestureRecognizerDelegate protocol. Instantiate the gesture recognizer. For example, to instantiate a UITapGestureRecognizer, we will do: UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)]; Here, action is the selector which will handle the gesture. Here, our selector … Read more

UIGestureRecognizer on UIImageView

Check that userInteractionEnabled is YES on the UIImageView. Then you can add a gesture recognizer. imageView.userInteractionEnabled = YES; UIPinchGestureRecognizer *pgr = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; pgr.delegate = self; [imageView addGestureRecognizer:pgr]; [pgr release]; : : – (void)handlePinch:(UIPinchGestureRecognizer *)pinchGestureRecognizer { //handle pinch… }

UIGestureRecognizer and UITableViewCell issue

Instead of adding the gesture recognizer to the cell directly, you can add it to the tableview in viewDidLoad. In the didSwipe-Method you can determine the affected IndexPath and cell as follows: -(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state == UIGestureRecognizerStateEnded) { CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView]; NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation]; UITableViewCell* swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath]; … Read more

tech