kodeco.com Forums

UIGestureRecognizer Tutorial: Getting Started

In this tutorial, you will learn how to configure UIGestureRecognizer objects and also create custom ones in code.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/433-uigesturerecognizer-tutorial-getting-started

Hi Brody, great tutorial! I definitely found it useful. For the custom UIGestureRecognizer, I believe it’s possible to simply import UIKit.UIGestureRecognizerSubclass directly into the Swift file instead of adding the bridging header. Do you know if there is any downside to using this approach?

1 Like

this tutorial don’t work in any way as described… but look at the case, the final project work fine…
pls stop making tuts

Wonderful tutorial! Very concise and easy to follow.

Hope to see more tutorials in this kind of concise instruction format.

Thank you for the wonderful tutorial :smiley:

@wviper3 great tutorial. but I’ve question. is there a way to resize the height and the width draging a corner of a view? if yes, how?


Hey @alex_andrews, it is possible to import UIKit.UIGestureRecognizerSubclass. I wasn’t aware of this so thanks for the tip! I don’t see any downside to importing directly in Swift and it saves you from having to create a bridging header. I was following Apple’s UIGestureRecognizer documentation which states:

The state property is declared in UIGestureRecognizer.h as being read-only. This property declaration is intended for clients of gesture recognizers. Subclasses of UIGestureRecognizer must import UIGestureRecognizerSubclass.h. This header file contains a redeclaration of state that makes it read-write.

@rufy Do you want to change the bounds of the image views that receive the gesture?

yes, that’s right. I want to show a view that has 1 or more corner on which the user can touch and drag to edit the dimension of view. is it possible?

You can use a custom UIGestureRecognizer to handle the touches and change view.transorm to resize the view. As for the corners, this stack overflow thread shows how to implement something like that.

Hi Brody, this tutorial really helped me! I implemented it elsewhere on a small View area with buttons. I can tilt and resize just fine. But when I press a button, the view re-centers itself on the screen. How can I maintain x-y through a simple button press?

@randy918 that seems to be some interesting behavior. Do you have any code you could send? Are you using a custom UIGestureRecognizer?

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!