Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable the user interaction for the Cancel button of my watchOS interface controller?

In my Apple Watch app, one of my interface controllers has a Cancel button at the top left corner. In my case, once a particular action is completed, I don't want the user to go back to the previous screen, so I want to disable the user interaction for that Cancel button. Even if I change the title to an empty string, user interaction still stays enabled.

like image 919
simbesi.com Avatar asked Jun 04 '15 11:06

simbesi.com


People also ask

How do I Reset my control Center on my Apple Watch?

Press and hold both the side button and Digital Crown for at least 10 seconds. Release both buttons when you see the Apple logo.

What are Crown haptics on Apple Watch?

Apple Watch Series 4 and later provides haptic feedback for the Digital Crown, which gives people a more tactile experience as they scroll through content. By default, the system provides linear haptic detents — or taps — as people turn the Digital Crown a specific distance.

How to open notification Center on Apple Watch?

Touch and hold the top of the watch face to open Notification Center. You can do this from any screen. Wait for Notification Center to show, then swipe down. Turn the Digital Crown to scroll, or swipe up and down on the watch face.


2 Answers

We can't disable the back/cancel button user intaraction but can load controller without cancel button.

presentControllerWithName("NewInterfaceController", context: nil)

presentControllerWithName this will present controller with cancel button. If we use like below won't get the cancel button.

WKInterfaceController.reloadRootControllersWithNames(["NewInterfaceController"], contexts: ["NewInterfaceController"])

reloadRootControllersWithNames this will make our controller as a root controller so we won't get cancel button. This is how i resolved my issue. Hope it will help you as well.

NOTE: here [ ] is the syntax. exp: ["NewInterfaceController"]

like image 156
simbesi.com Avatar answered Sep 22 '22 14:09

simbesi.com


You can't disable user interaction for back button.

But you can change a bit the way you present your views to accomplish what you want.

Start with your normal view. Check if you need to show the user the login. If you do, then present the login view Modally. At the end of login you close the modal view and you're back to normal view, without unnecessary back button.

like image 24
pteofil Avatar answered Sep 22 '22 14:09

pteofil