iOSGestures (using iOS Gesture Recognizers)

  1. ‹ Older
  2. 3 years ago

    Stephen J

    12 Jan 2015 Pre-Release Testers, Xojo Pro

    I've been planning on doing a minor refactor/tune up of the iOSGestures module.

    If you could tell me what is missing I might be able to add it to the module for you.

    Your code (attaching UITapGesture to a button) got me interested enough to put together a very simple project just to see what would happen. I created a view with an iOSButton on it and attached a tapGesture set to watch for double-taps on the button. The button worked fine, you could both single and double tap the button which I guess shows the advantage of using Apple's system recognizers instead of rolling our own.

    I'll add MultiTapButton to the Example project when I finish the update but here is a temporary dropbox link if you are interested. Attaching the tapGesture took 4 lines of code (plus adding a property and the actual tap and double event handlers) but it could all have been reduced to a single line with a gesture specific constructor.

    Add property tapHandlerForButton of type tapGesture to View1
    Add method "tapHandler" with parameters "recognizer as iosGestures.tapGesture, pos as xojo.Core.Point, eventInfo as iosGestures.gestureEventInfo" to View1]
    In View1 Open Event add:
    tapHandlerForButton = new iOSGestures.tapGesture()
    tapHandlerForButton.NumberOfTapsRequired = 2
    AddHandler tapHandlerForButton.Tap, AddressOf tapHandler
    tapHandlerForButton.Attach( MultiTapBtn.Handle )

    https://dl.dropboxusercontent.com/u/242430/MultiTapButton.zip

    === Nothing is this post should be considered as supporting the idea of actually implementing a multi-tap button in an app's UI ===

  3. Ulrich B

    13 Jan 2015 Pre-Release Testers, Xojo Pro Europe (Germany, Berlin) · xo...

    Thanks again, Stephen! I would have liked to build a native declare version, with no need to add Xojo GestureRecognizers to a class, but I've come to the conclusion that would be too much uncertain work with probably no real use when mostly controls having built-in GRs like buttons will be used, and for the other cases your implementation is brilliant (and would need subclasses anyway).
    Would you oppose against me adapting your class with a few convenience methods to my lib, of course with full reference to it? I would rather restrain to adding more functions to it – the old UIVIew animation classes are now fully available in the iOSControl extension module ;-)

  4. Jason T

    27 Feb 2015 Pre-Release Testers, Xojo Pro Sydney, Australia

    @Stephen J;Beardslee thank you for your contribution with XojoGestures! Great work!

    Is it possible to make this work with ImageView controls? I have an image viewer that adds multiple ImageView controls to a view and I'd like users to be able to tap an individual image to open it in another view. I realise I could use Canvas controls instead of ImageView controls, however the in-built ScaleAspectFill property of the ImageView is very fast and produces a much better image than drawing into a Canvas at a reduced scale.

  5. Jason K

    27 Feb 2015 Pre-Release Testers
    Edited 3 years ago

    Hi Jason, I know this isn't for iOSGestures (I haven't looked through his code enough to understand what is/isn't possible) but with my UITapGestureRecognizer in UIKit of iOSKit you should be able to detect a tap. The following code in the view open event should do it:

    Declare sub addGestureRecognizer lib "UIKit" selector "addGestureRecognizer:" (ctrl as ptr, recognizer as ptr)
    //recognizer1 is a UITapGestureRecognizer dragged onto the view
    //imageView1 is an iOSImageView dragged onto the view
    addGestureRecognizer(imageView1.handle, recognizer1)

    You would then receive the gesture event in the recognizer1 object. Maybe this helps?
    Jason

  6. Jason T

    27 Feb 2015 Pre-Release Testers, Xojo Pro Sydney, Australia

    Thanks Jason. I'm using some of your classes that were provided outside of the latest iOSKit Github code and so dropping UIKit into my app is causing me some grief. For example, I have your UISearchBar with a GotFocus event definition but the one in iOSKit does not have that. There seem to be a few other issues as well. But I'll try to work out how to slice and dice the gesture stuff to get it into my app. :)

  7. Jason K

    27 Feb 2015 Pre-Release Testers

    Thanks for letting me know that, I'll fix that when I update the code. Looks like I overlooked updating the UISearchbar after adding that for you.

  8. Jason T

    27 Feb 2015 Pre-Release Testers, Xojo Pro Sydney, Australia
    Edited 3 years ago

    Thanks Jason. I've tried updating my UIKit and putting back the UISearchBar but I get a series of build errors in my Views that have a UISearchBar, viz:

    Location: ViewName.UISearchBar.Name Layout (property name). Issue: Type "Text" has no member named "UISearchBar" Name.

    I hope you're not going to tell me to delete and re-add them. The Auto-Layout implications could send me over the edge! ;)

  9. Jason K

    28 Feb 2015 Pre-Release Testers

    That is possibly the least helpful error message I have seen in Xojo :) Maybe @Joe R would have an idea what would cause that message? I plan to update iOSKit in the next day or two and it will include the new UISearchBar, maybe that will help.

    Jason

    PS. We might want to take this to PM since it's heading off topic ;)

  10. Jason T

    1 Mar 2015 Pre-Release Testers, Xojo Pro Sydney, Australia

    I don't want to take this off-topic but I just want to post this bit of information in case it helps anybody else in the future. I have found that answers to other people's problems very often help me solve my problems when I conduct a form search, which makes this forum an extremely valuable resource.

    The fix for the "Type "Text" has no member named..." error was to remove the prefix for the UISearchBar control's Super name. So the super was set to "UIKit.UISearchBar" and by removing "UIKit." the error was not longer reported.

    Now, back on topic ! :)

  11. Stephen J

    2 Mar 2015 Pre-Release Testers, Xojo Pro

    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 T 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.

  12. Stephen J

    2 Mar 2015 Pre-Release Testers, Xojo Pro

    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.

  13. Michel B

    2 Mar 2015 Pre-Release Testers, Xojo Pro
    Edited 3 years ago

    @Stephen J;Beardslee 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.

  14. Jason T

    2 Mar 2015 Pre-Release Testers, Xojo Pro Sydney, Australia

    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... ;)

  15. Jason T

    2 Mar 2015 Pre-Release Testers, Xojo Pro Sydney, Australia

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

  16. Stephen J

    2 Mar 2015 Pre-Release Testers, Xojo Pro

    @Jason T 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]

  17. Stephen J

    18 Apr 2015 Pre-Release Testers, Xojo Pro
    Edited 3 years ago

    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.

  18. 2 years ago

    Ali O

    25 Nov 2015 Pre-Release Testers, Xojo Pro Netherlands

    @Stephen J;Beardslee

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

  19. Stephen J

    25 Nov 2015 Pre-Release Testers, Xojo Pro
    Edited 2 years ago

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

  20. Ali O

    26 Nov 2015 Pre-Release Testers, Xojo Pro Netherlands

    @Stephen J;Beardslee

    Thank you for making that possible.

  21. 4 days ago

    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.

or Sign Up to reply!