How to show an error in an apple watch

How to handle exception cases, such as a stand-alone error in apple tea, I cannot find anything in the Apple Watch programming guide.

Does the overlay support apple text? or you need to make ui mistake yourself.

+4
source share
3 answers

WatchKit does not yet provide alerts or UI errors (as of March 2015). You will have to do it yourself.

One easy way is to create a custom class that implements the WKInterfaceController and creates an interface in the Storyboard. Then use presentControllerWithName:context:to display it in text format.

ErrorInterfaceController:

import WatchKit
import Foundation

class ErrorInterfaceController: WKInterfaceController {

    @IBOutlet weak var errorMessageLabel: WKInterfaceLabel?

    override func awakeWithContext(context: AnyObject?) {
        super.awakeWithContext(context);

        if let dictionary = context as? [String: String] {
            if let message = dictionary["message"] {
                errorMessageLabel!.setText(message)
            }
        }
    }

    @IBAction func closeModalView() {
        dismissController()
    }
}

:

private func showError(#message: String!) {
    presentControllerWithName("ErrorInterfaceController", context: ["message": message]);
}
+4

WatchKit, label.

, .

0

WatchKit does not provide any alerts similar to UIAlertControllerthose you find in UIKit.

You can introduce a new interface controller and display information on this screen, and then add buttons to it if the user needs to take action (for example, to reject it).

0
source

All Articles