Glances

PDF for offline use
Sample Code:
Related Links:

Let us know how you feel about this

Translation Quality


0/250

last updated: 2016-09

NOTE: Glances are no longer supported in watchOS 3.

A watchOS 1 or watchOS 2 app can contain only one glance interface, which is a read-only non-interactive view of app data. Having a Glance in your app is optional.

Creating a Glance

The glance view is an instance of WKInterfaceController. It can only display data to the user - it cannot be interactive. The glance content must also fit onto one screen - it does not support scrolling.

Tapping on the glance view automatically runs the full watch app.

The glance interface controller is activated by a special segue in the storyboard:

When you drag a new Glance Interface Controller onto a storyboard it will automatically have the segue attached. There should only be ONE glance in your app storyboard (there will be a build error if you try to compile with more than one present).

Use the Awake and WillActivate methods to configure the glance's appearance and behavior before it is displayed.

The glance cannot contain interactive elements, but if the user taps the glance it will start the watch app. You can pass information to the app using UpdateUserActivity as shown in the WatchKitCatalog sample:

using (var d = new NSDictionary ("controllerName", "imageDetailController",
"detailInfo", "This is some more detailed information to pass.")) {
    // Use Handoff to route the wearer to the image detail controller when the Glance is tapped.
    UpdateUserActivity ("com.example.apple-samplecode.WatchKit-Catalog", d);
}

Testing Glance Mode

You can start the app in glance from within the IDE, but the process is slightly different to starting the app normally.

Xamarin Studio will display additional options when a watch extension is set as the Startup project:
Right-click on the watch extension project and choose Run With > Custom Parameters...:

This opens the Execution Arguments window which contains a WatchKit tab.Select Glance and press Execute to start the watch app in the simulator:

Visual Studio will display additional options when a watch extension is set as the Startup project - choose one of the Glance options to start the watch app in Glance mode:

It is also possible to use the command line to start the iOS Simulator.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.