iOSGestures (using iOS Gesture Recognizers)

Warning: While looking into this I found that the iosGestures-ExampleOne project is broken by 2015-R1 so feel I need to get that working so the repo isn’t poisoned.

@Jason Tait Once that is fixed I’ll see what I can do for controls that currently are not included in the chain of command such as ImageView. (Notice that ImageViewer doesn’t have the same touch events that Canvas does.)

Until then one workaround, if you want to use iosGestures for this, is to use a canvas to catch the gestures and a seperate ImageView to display the image. For each ImageView, first put down a canvas down where you want the ImageView to go, then an ImageViewer over the canvas, then attach your gestures to the canvas.

The reason to put the ImageView onto the Canvas is to make sure that the Canvas is NOT a child of the ImageView (you don’t see the red ring on the ImageView when you click the Canvas in the control list on the left). If the Canvas is the child the ImageView will eat your gestures since the parent isn’t in the chain of command, its children won’t be either.

As far as I could figure it out, if you first place a control out of the view, and then move it in using only the constraints, it does not become child of existing controls. Only when you move a control with the mouse does it become child. It is cumbersome but effective.

I do not understand why Parent has become readonly, though. It would be much easier to do Parent = Nil like in Desktop. But given the deafening silence from Xojo team about that, I guess we can forget about getting modifiable Parent. Maybe it is simply impossible in iOS.

Thanks guys. I’ll try using the Canvas as Stephen mentioned. I build this view dynamically by adding ImageView controls at runtime so I should be able to avoid the Parent/Child issue. Now if I could just get my 9 year old off to school in the next 10 minutes, I’ll avoid a very different sort of Parent/Child issue at home… :wink:

Just confirming that an iOSCanvas placed under each iOSImageView works as Stephen suggested.

@Jason Tait Cool, I’m glad that is working for you.

Re: Fixing Parent/Child control issues: I already posted this in another thread on this issue but one trick I found while working on ExampleOne was that my opening/main view was suffering from some parenting issues and the easiest fix was to delete the control (a table in my case) that was the unwanted parent of assorted stuff and then undo the delete right away. When deleted it took all its children with it but when it all came back they were no longer parent/child just controls on the same page. I wouldn’t count on it always working but it saved we having to rebuild/tweak that page up from scratch again. Of course, save first or try this on a copy before deleting controls/code you can’t replace. [too bad it wasn’t the only issue that needed to be fixed]

I’ve posted an update to iOSGestures on gitHub (sbeardsl/xojoGestures) that provides support for Xojo 2015 R2.

However, I lack 64-bit hardware to test on and the simulator doesn’t seem to support that yet meaning that while the code has been edited to work on 64-bit devices it hasn’t actually been tested on any. If you give it a try on any true 64-bit please let me know how it goes. I’ll do my best of fix any issues that come up (crash log are very helpful).

Warning: I was never able to get iOSGestures to work on 2015 R1.
For those still on 2014 R3.2 I’ve included a binary project built and tested on that release.

@Stephen J. Beardslee

iOSGestures runs without problems on a 64bit iPhone 6s plus running iOS 9.1.

Thanks for the update @Ali Odaci. I’m glad to know it’s working for you.

@Stephen J. Beardslee

Thank you for making that possible.

Anyone encountered an issue where the scale parameter in the method called PinchChanged has a really high value even when I do a small pinch?

This is happening in the ExampleOne app on my Release 2017 2.1 XOJO build.

2018 and gestures still dont seem to be part of the standard iOS product.
Whats the simplest way to add them?
This module says it is compatible with 2015 onwards, but the example project wont run due to a missing class baseGestureRecognizer

I hear that iOSLib has lots of functions, but it seems to drag a whole warehouse of classes , functions, declares, and properties to get out of bed. Cant use UIKIt on its own, for example
I also think I saw someone say iOSLib is dead, and replaced by AppleLib, which I cant find.

SO:
two finger drag, two finger pinch and zoom - is there yet a non-declare method, and if not, whats the smallest footprint library?
(I’m close to release and have managed to get here with only one declare so far, ShowURL)

UIkit might have a lot of classes, but only what you use is compiled in the final project, if I’m not mistaken.

Everything you don’t use is compiled out so it doesn’t increase app size. If you want the most bare bones possible version with iOSKit you just need the UIKit, Foundation, and Extension modules I believe. Those 3 are the common dependencies of the other modules.

Fair enough.
Im happy that the unused code woudn’t increase the project size.
Still struggling to work out how to use this, but every day is a school day.

So, I have Pan gesture hooked up.
It fires when I use one finger on the device, which I wasnt expecting - the convention would be two.
However, while I have a pan gesture in place, the eventinfo no longer reports pointercount correctly as 1 or 2
So I can either detect the pointer has moved and it always pans, or I can ‘draw’ but I cant pan.

What I need to do is draw while one finger is moving, and pan while two fingers are moving
What am I missing?

Edit: There is a minimum touches property on the Pangesture control. That needed setting to 2
Wow. This has taken a whole day to get working, and thats even though Stephen did so much of the groundwork.