Gesture recognition in Apple Watch (WatchKit)

11,917

Solution 1

As far as I can tell, there is no way to do it. Whole Apple Watch is super limited when it comes to what can you do with it. I suppose that kind of makes sense since it should be just peripheral to your main app but it's a bit too limited for my liking.

Solution 2

Do you read the iWatch Guide? Apples say´s:

Gestures: The system handles all gestures on your behalf, using them to implement standard behaviors:

  • Vertical swipes scroll the current screen.
  • Horizontal swipes display the previous or next page in a page-based interface.
  • Left edge swipes navigate back to the parent interface controller.
  • Taps indicate selection or interaction. Taps are handled by the system and reported to your WatchKit extension’s action methods.

Apple Watch does not support multi-finger gestures such as pinches.

...taken from Apple iWatch Human Interface Guidelines. So i don´t think this "hack" give you the same behavior as in iOS.

Solution 3

Apple automatically provides to the user swipe gestures to navigate forward and back through your controllers, and to scroll the views the Watch has laid out. All of this is done without requiring any code or gesture configuration by the third party developer. All we have ability to do is define the segues and layout of the objects in Interface Builder and the OS takes care of the rest.

There is no direct access to swipes or other gestures or tap locations in WatchKit at present, and there is no reason to believe that is going to change before the release of the Watch.

It is unclear whether Apple may be willing to enable this in the future, or whether they will never open this up to developers, but they are encouraging developers to submit enhancement requests via their bug reporter. Be sure to describe your desired use case and the problem you're trying to solve, as well as what your proposed solution is, as there may be a different facility they can provide that will solve your problem case even if it does so in a different way than we expect.

Share:
11,917

Related videos on Youtube

Smile2Life
Author by

Smile2Life

Updated on June 04, 2022

Comments

  • Smile2Life
    Smile2Life almost 2 years

    I'm looking for how to detect gestures in an Apple Watch app, via the WatchKit SDK. In iOS we can use some code like this:

    - (void)viewDidLoad
    {
        ...
        UISwipeGestureRecognizer *swipeRightBlack = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(slideToRightWithGestureRecognizer:)];
        swipeRightBlack.direction = UISwipeGestureRecognizerDirectionRight;
        [self.viewBlack addGestureRecognizer:swipeRightBlack];
    }
    

    ...but this doesn't work in the Apple Watch simulator. Is there a way to override the default gesture actions using WatchKit, or just recognize them when the OS receives them?

  • Jesper
    Jesper over 9 years
    There will be a full app API coming during 2015. The current support is just the first step.
  • Smile2Life
    Smile2Life over 9 years
    hmm that was expected, as listed here developer.apple.com/library/prerelease/ios/documentation/…, just looking for someone that made a hack or something that can help before the official WatchKit realize :D
  • Duncan Babbage
    Duncan Babbage over 9 years
    Apple have confirmed that 'full native apps' will be available later in 2015. I don't think we can assume that the API will necessarily look like what we have in iOS. The current WatchKit API is designed around the need for the Watch to only be displaying the interface, but that doesn't necessarily mean that we will have full access to everything even when apps are running natively. Hopefully, of course. Time will tell.
  • Cihan Tek
    Cihan Tek almost 9 years
    And those "automatic" swipe gestures are buggy as hell. All of the applications I tried, including the one I'm developing has its navigation stack messed up whenever I use the interactive pop gesture. Once you go back with swiping, you cannot go to another screen properly.