WatchKit - Force Touch API Questions

237 Views Asked by At

Some questions to the Force Touch Menu:

  1. Now when I perform a Force Touch and press one of my menu Items, the whole InterfaceController, where my Menu is implemented is loading new. Is this avoidable?

  2. I've implemented a menu with 4 menuItems for my InterfaceController.

With one of this menuItems, I want to enable/disable the haptic Feedback of my Buttons.

My button methods are like this:

- (IBAction) but1Pressed {
       [[WKInterfaceDevice currentDevice] playHaptic:WKHapticType.Click];
       // Do something
}

How can I disable the TapticEngine, if the user disables it ind the ForceTouchMenu?

1

There are 1 best solutions below

1
On BEST ANSWER
  1. No, as by today that's not possible.

  2. If I understand you properly, you need a BOOL which defines whether the app should perform haptic feedback when a button in your interface controller is being pressed.

To realise that, implement the following:

BOOL shouldGiveTapticFeedback = YES

Then you need a method to change this BOOL when the corresponding menu item is being pressed:

- (IBAction) tapticFeedbackChangeButtonPressed {

   //change BOOL value

   shouldGiveTapticFeedback = !shouldGiveTapticFeedback

}

Finally, you need to check whether the taptic feedback should be played, when a button in your interface controller is being pressed:

- (IBAction) interfaceButtonPressed {

   if(shouldGiveTapticFeedback) {

      //play sound

      [[WKInterfaceDevice currentDevice] playHaptic:WKHapticType.Click];

   }
}
  1. No, that's not possible either.