complication
TRANSCRIPT
watchOS 2 Transition Guide
https://developer.apple.com/library/prerelease/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/DesigningaComplication.html#//apple_ref/doc/uid/TP40015234-CH11-SW1
Creating Complications with ClockKit
https://developer.apple.com/videos/wwdc/2015/?id=209
Complication Families
https://developer.apple.com/library/prerelease/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/DesigningaComplication.html#//apple_ref/doc/uid/TP40015234-CH11-SW1
• Complication Familiesごとにレイアウトが複数用意されている
• 全てのComplication Familiesをサポートする必要はない
Complication Families
Creating complication with ClockKitより
Complication Families
Modular small
Modular large
Utilitarian small
Utilitarian
Creating complication with ClockKitより
Complication Families
Modular small
Modular large
Utilitarian small
Utilitarian large
Utilitarian
Creating complication with ClockKitより
Complication Families
Modular small
Modular large
Utilitarian small
Utilitarian large
Circular small
Circular
CLKComplicationTemplate
Utilitarian SmallModular Large
Utilitarian Large
11:00AM
Group DHaight – Twin Peaks
Modular Small Circular Small
CLKComplicationTemplate
Creating complication with ClockKitより
CLKComplicationTemplate
class CLKComplicationTemplateModularLargeStandardBody {
var headerImageProvider: CLKImageProvider?
var headerTextProvider: CLKTextProvider
var body1TextProvider: CLKTextProvider
var body2TextProvider: CLKTextProvider?
}
CLKComplicationTemplate
11:00AM
Group DHaight – Twin Peaks
Body 2 textBody 1 text
Header image Header text
Creating complication with ClockKitより
CLKComplicationTemplate
• 文字列はCLKTextProviderとCLKTextProviderを継承したクラス
• 表示形式に適したCLKComplicationTemplateを選んで使用する
// complicationでTimeTravelでサポートする方向- getSupportedTimeTravelDirectionsForComplication:withHandler:
CLKComplicationDataSource
struct CLKComplicationTimeTravelDirections : OptionSetType { init(rawValue rawValue: UInt) static var None: CLKComplicationTimeTravelDirections { get } static var Forward: CLKComplicationTimeTravelDirections { get } static var Backward: CLKComplicationTimeTravelDirections { get }}
CLKComplicationTimeTravelDirections
TimeTravelでサポートする方向を決める
// 開始時間- getTimelineStartDateForComplication:withHandler:
// 終了時間- getTimelineEndDateForComplication:withHandler:
CLKComplicationDataSourcecomplicationに表示する情報のサポート時間範囲
• 範囲外の時間になったらcomplicationが暗転する
- getPrivacyBehaviorForComplication:withHandler:
CLKComplicationDataSourcecomplicationに表示するデータのプライバシー設定
CLKComplicationPrivacyBehaviorShowOnLockScreenCLKComplicationPrivacyBehaviorHideOnLockScreen
ロック時に表示させたくない場合はCLKComplicationPrivacyBehaviorHideOnLockScreenを返す
// 現在の時間のデータを返す- getCurrentTimelineEntryForComplication:withHandler:
// TimeTravelで過去の時間のデータを表示させる際に使用- getTimelineEntriesForComplication:beforeDate:limit:withHandler:
// TimeTravelで未来の時間のデータを表示させる際に使用- getTimelineEntriesForComplication:afterDate:limit:withHandler:
CLKComplicationDataSourcecomplicationに表示するデータの設定
- getPlaceholderTemplateForComplication:withHandler:
CLKComplicationDataSourcecomplication設定時に表示するデータを設定
• データソースのメソッドは最小限にとどめておくこと
The implementations of your data source methods should be minimal.
• 通信してデータを取ってくるとか計算とかデータの転送が遅れるようなことはしない
Do not use your data source methods to fetch data from the network, compute values, or do anything that might delay the delivery of that data.
• データの取得や計算が必要な場合はiOSアプリ側で行ったり、WatchKit extensionの別の場所で行い、それをcomplicationからアクセス可能な場所にキャッシュさせて使用すること
If you need to fetch or compute the data for your complication, do it in your iOS app or in other parts of your WatchKit extension and cache the data in a place where your complication data source can access it.
• データソースのメソッドではキャッシュしたデータを取ってきて、ClockKitの要求するフォーマットに設定するだけにするThe only thing your data source methods should do is take the cached data and put it into the format that ClockKit requires
注意点