Alexey Chulochnikov, mobile developer with 3+ years of experience, about:
• Watch App architecture overview
• Apple watch interface overview (Regular Apple Watch App, Glances, Notifications)
• Initial Impressions about WatchKit
• How to work with watchkit (pass data between controllers, get data from parent app, etc.)
6. Interface controllers
life cycle
Display UI
User interacts
with UI
User stops
interacting
willActivate
various action
methods didDeactivate
Suspend
extension
Interface controller
21. More information
WatchKit App Architecture
http://bit.ly/watchKit_app_architecture
App Components
http://bit.ly/app_components
UI Elements
http://bit.ly/ui_elements
HipChat
http://bit.ly/ciklum_apple_watch
BitBucket
https://bitbucket.org/WooD1k/watchcurrency
Slides
http://bit.ly/ciklum_watch_slides
Editor's Notes
init and awakeWithContext methods are used for:
- load any required data
- set values of interface objects
prepare interface to be displayed
willActivate method is used for:
- "last-minute" changes
- show animation
- other tasks that should be shown while interface is displaying\on screen
didDeactivate:
to clean up your interface and put it into a quiescent state(invalidate timers and stop animations)
you cannot set values for any interface objects from this method
Labels
Images
Tables
Buttons
Switches
Sliders
Use groups to arrange items horizontally or vertically.
Nest groups to mix horizontal and vertical content.
A group has attributes for specifying position, size, margins, background image, color, and corner radius that can transform it into a visual element.
Maps are static snapshots of geographic locations.
You place a map in your interface at design time, but you must configure the displayed region at runtime. The displayed region is not interactive, but tapping a map will open the Maps app on Apple Watch.
You can annotate a map to highlight points of interest or other relevant information. A map can display the standard green, red, and purple pins. It can also display custom images. The system lets you add up to five annotations to a map.
date label displays the date, the time, or a combination of both. It can be configured to use a variety of formats, calendars, and time zones.
timer label displays a precise countdown or count-up timer. It can be configured to display its count value in a variety of formats.
Force touch on the Apple Watch display cause the current screen’s menu (if any) to appear. A menu can display up to four relevant actions for the current screen without taking away space from your interface.
Menus are optional. If no menu is present, the system plays an animation when the wearer presses firmly on the display.
Use a label and an icon to convey the purpose of each menu action. Both the label and the icon are required. Labels are limited to two lines, so the text should be short.
Make glances contextually relevant.
Avoid using your glance solely as an app launcher.
Make content quick and easy to read.
Left align glance content.
Short looks appear briefly, giving the wearer just enough time to see what the notification is about and which app sent it.
Short looks:
make titles short and easy to understand
keep privacy in mind
Custom long looks come in static and dynamic versions.
The content area of the static and dynamic long looks is fully customizable, but the overall structure of the interface is not. The system-provided sash at the top displays the app icon and name. You can customize the sash’s color or give it a blurred appearance. Buttons for custom actions appear below the content area. The system always adds a Dismiss button to your interface and places it after your custom buttons.
Apple Watch shares the interactive notification types already registered by your iOS app and uses them to configure custom action buttons. The system determines which buttons to display based on a notification’s type and automatically adds a Dismiss button after all custom buttons.
The first parameter is a user info dictionary that can contain any data you like, as long as it conforms to the plist data format.
iOS app will receive this object at the other end, so you can pass in any options you need here.
You’ll call this method in response to openParentApplication(_:reply:)
After the request comes back, you call the reply handler
you need to archive the array into an NSData instance so it survives the trip back to WatchKit
Here you inform WatchKit that there’s a user activity going on. In this case, the user is glancing at a certain currency.
The first parameter is the activity type, which is just a string that identifies the activity using reverse domain notation.
You also pass a userInfo dictionary to the Watch app when it’s launched via tapping the glance.
The third parameter, webpageURL, is used for watch-to-iPhone Handoff. As of this writing it’s not available and isn’t relevant in this context, so you simply pass nil.
handleUserActivity(_:) is called only on the initial interface controller — as denoted by the Main arrow in the storyboard
Every interface controller accepts a context parameter, which is an optional AnyObject
WatchKit calls this method when the user taps on a table row, as long as the row type has a segue connected to it.
Your job is to return an object that will be passed into the destination controller as the context parameter.