Changes

An Overview of WatchKit Tables in watchOS 2

50 bytes added, 20:02, 27 October 2016
m
Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">"
<googlehtmlet>BUY_WATCHOS2watchos2</googlehtmlet>
When a scene containing a table is displayed within a WatchKit app, the table object will need a row controller instance for each row to be displayed to the user. The interface controller is responsible for performing the following initialization tasks:
1. Calculate the number of rows to be displayed in the table.<br>2. Request the creation of a row controller instance of a particular row controller type for each row in the table.<br>3. Configure the appearance of the user interface objects in each row using the outlets declared in the row controller class.<br>
== Implementing a Table in a WatchKit App Scene ==
As previously outlined, each row controller type must have a corresponding row controller class file within the app extension. This must be a subclass of NSObject and can be created using the following steps:
1. Locate the WatchKit Extension folder within the Project Navigator panel and Ctrl-click on it.<br>2. From the resulting menu select the New File… menu option.<br>3. In the new file template panel, select Source listed under watchOS in the left hand panel and WatchKit Class from the main panel before clicking Next.<br>4. Enter a name for the class into the Class field and select NSObject from the Subclass of: menu before clicking Next.<br>5. Click Finish to add the new class to the extension.<br>
== Associating a Row Controller with a Row Controller Class ==
Before the table can be displayed, the row controller in the scene needs to be associated with the corresponding row controller class residing within the extension. This is achieved by selecting the row controller in the Document Outline panel, displaying the Identity Inspector (View -> Utilities -> Show Identity Inspector) and selecting the row controller class name from the Class menu.
<googlehtmlet>BUY_WATCHOS2watchos2</googlehtmlet>
== Creating Table Rows at Runtime ==
<googlehtmlet>BUY_WATCHOS2watchos2</googlehtmlet>
 
<htmlet>ezoicbottom</htmlet>
<hr>
<table border="0" cellspacing="0" width="100%">