iosmodal-dialogwatchkitmodalviewcontrollerwkinterfacecontroller

Prevent dismissing modal WKInterfaceController


Is there a way to prevent the user from dismissing a modal controller?

I think it is pretty common to want to "block" the main Watch App interface while asking the user to open the iPhone counterpart or to perform some action there.

My current solution is to present again the controller when it gets dismissed but its clunky.


Solution

  • You can't prevent a modal interface controller from being dismissed, as the system automatically dismisses it when the title is tapped.

    Since your code isn't asked if it should happen, but only knows that it is happening, there's no way to intercept or cancel that action. The WKInterfaceController documentation briefly touches on this.

    When the user taps the title string, WatchKit automatically dismisses the modal interface without taking any further actions.

    What can you do?

    While you don't know when the Cancel title is tapped, there is a hack which "hides" the Cancel title.

    This may confuse users who might wonder how to dismiss the modal, or mislead others into thinking the modal couldn't be dismissed.

    What does the HIG recommend?

    Circumventing a Human Interface Guideline would likely degrade the entire user experience.

    The top-left corner of the modal sheet is reserved for the Close button, which dismisses the interface.

    Some users might be frustrated or annoyed if

    Since the user expects to be able to dismiss the modal, perhaps you could allow them to do just that, then simply display some form of reminder in the presenting interface controller (to log in, or enable permissions).