![]() The next step, therefore, is to add this class. ![]() On completion of these steps, the layout of the scene should resemble that of Figure 7-2:ĭisplay the Document Outline panel, select the Table Row Controller object from the hierarchy, display the Attributes Inspector panel and enter “MyRowController” into the Identifier field (Figure 7-3):Īs discussed in the chapter entitled An Overview of WatchKit Tables, each row controller in the table must have associated with it a row controller class within the app extension. Within the Size section of the panel set both the Height and Width attributes to be Fixed at 25 points. In the Position section of the panel change the Vertical menu to Center so that the image is in alignment with the label object.ģ. Set the Mode menu to Aspect Fit so that images are not distorted when displayed.Ģ. Select the Image object and make the following changes within the Attributes Inspector panel:ġ. Select the label and, using the Attributes Inspector panel, set the Vertical position menu to Center. Repeat this step, this time selecting a Label object and positioning it to the right of the Image object. Within the Object Library panel, locate the Table object and drag and drop it onto the scene layout so that it appears as shown in Figure 711:ĭrag an Image object from the Object Library panel and drop it onto the table row in the storyboard scene so that it is positioned on the left hand side of the row. Those methods should be implemented because the ToDoListTableViewController class interface is conforming to UITableViewDataSource and UITableViewDelegate protocols.Navigate to and select the storyboard file for the WatchKit app (TableDemoApp WatchKit App -> Interface.storyboard) so that it appears in the Interface Builder tool. Open the new ToDoListTableViewController.m, you will see the method signatures created automatically by Xcode. Pick the Cocoa Touch Class template:Ĭlick Next, call the class ToDoListTableViewController and make sure it’s a sub-class of UITableViewController: By having this Sub-class, Xcode inserts the method signatures for most of the methods we need, for the TableView data source and the TableView delegate.įirst delete the current ToDoListViewController.h and ToDoListViewController.m, then select the File -> New -> File menu option. To make the configuration of the TableView easier, we will be creating a new Sub-class from the UITableViewController class. In this application we will be using a TableView to display the to-do list. I’ll first rename my parent ViewController from ‘ViewController’ to something descriptive, like ‘ToDoListViewController’: Expand the iOS application’s classes group: We will start by developing our parent iOS application. Select the WatchKit app template.Ĭlick Next and deselect the options for creating a Notification scene or Glance scene.Ĭlick Finish and Activate in the subsequent dialog to add a new target to the Xcode project, with new groups created for the WatchKit App and Extension. Select the File -> New -> Target menu option. Give it a relevant name and set the language to be Objective-C. Open Xcode and create a new Single View Application project. This will be a long tutorial, so you may find it useful to refer to the complete project on GitHub. ![]() In this final part, we look at coding these options. In the last part of this short series we looked at the options for communicating between WatchKit extensions and their host iOS Applications.
0 Comments
Leave a Reply. |