Changes

A watchOS 2 Complication Tutorial

435 bytes added, 20:01, 27 October 2016
m
Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">"
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="20%">[[An Overview of ClockKit and Apple Watch Complications|Previous]]<td align="center">[[watchOS 2 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Supporting Different Apple Watch Display Sizesin watchOS 2|Next]]</td>
<tr>
<td width="20%">An Overview of ClockKit and Apple Watch Complications<td align="center"><td width="20%" align="right">Supporting Different Apple Watch Display Sizesin watchOS 2</td>
</table>
<hr>
<googlehtmlet>BUY_WATCHOS2watchos2</googlehtmlet>
[[Image:Examplewatchos_add_complication.jpgpng]]
Figure 29-1
[[Image:watchos_complication_controller.png]]
Figure 29-2
[[Image:watchos_complication_extension.png]]
Figure 29-3
[[Image:watchos_select_complication_families.png]]
Figure 29-4
The settings configured in this panel are stored in the Info.plist file of the extension target and can be reviewed by selecting this file within the Project Navigator panel. Once selected, the relevant properties will appear in the property editor as shown in Figure 29-5:
[[Image:watchos_complication_plist.png]]
Figure 29-5
[[Image:watchos_image_added_to_complication.png]]
Figure 29-6
A number of the methods in the data source class will need to create complication timeline entries. Rather than duplicate code in multiple methods it is more efficient to write a single utility method and call that whenever a timeline entry is needed. This method will be named createTimeLineEntry and will take as parameters the header and body text to be included in the complication and the date of the timeline entry in the form of an NSDate object. The code for the method will also incorporate the beer glass icon into the entry before returning the result in the form of a completed CLKComplicationTimelineEntry object. Within the ComplicationController.swift file, implement this method as follows:
<googlehtmlet>BUY_WATCHOS2watchos2</googlehtmlet>
<pre>
func createTimeLineEntry(headerText: String, bodyText: String, date: NSDate) -> CLKComplicationTimelineEntry {
[[Image:watchos_clock_face_selection.png]]
Figure 29-7
[[Image:watchos_compliction_config.png]]
Figure 29-8
[[Image:watchos_complication_in_config.png]]
Figure 29-9
[[Image:watchos_complication_current_entry.png]]
Figure 29-10
[[Image:watchos_complication_time_travel.png]]
Figure 29 -11
<googlehtmlet>BUY_WATCHOS2watchos2</googlehtmlet>
 
<htmlet>ezoicbottom</htmlet>
<hr>
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="20%">[[An Overview of ClockKit and Apple Watch Complications|Previous]]<td align="center">[[watchOS 2 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Supporting Different Apple Watch Display Sizesin watchOS 2|Next]]</td>
<tr>
<td width="20%">An Overview of ClockKit and Apple Watch Complications<td align="center"><td width="20%" align="right">Supporting Different Apple Watch Display Sizesin watchOS 2</td>
</table>