![]() Select through the choices to get the Watchkit Extension file TableRowController.swift.įrom the circles to the left of the outlets, connect the outlets to the controls on the storyboard: Click at the top where it says Automatic and select Manual. Most likely you will see the InterfaceController.swift file in the assistant editor. Xcode assumes you want to work with the interface. In the identity inspector, change the Class to TableRowController. Click on the row controller named row in the document outline. ![]() Now we connect our row controller to the table. We’ll discuss actions in row controllers in the second part of the series. You can add actions, but for our basic example we’ll stick to just outlets. In our example, add two outlets for WKInterfaceLabel, splits and time.Ĭlass TableRowController: NSObject weak var splits: weak var time: WKInterfaceLabel! Typically they contain the outlets for the controls in the row controller. Since this is a WatchKit project and not an iOS one, change import UIKit Be careful that Xcode does not default you to the app. Save the file in the WatchKit extension group. Create a new Cocoa Touch Class named TableRowController. Our next step in building a table is making a table row controller. ![]() Set the Height Size to Size to Fit Content. In the attribute inspector, make the identifier rowĬlick the group for the row controller. Row controllers need unique names in the table. In the third part of this series on tables, we’ll work with multiple row controllers.Ĭlick on the Table Row Controller in the document outline. You may have one row controller for the data, one for a header and one for a footer for example. Tables can have more than one row controller. Most typically labels or images, but we can add buttons. In each row controller is a group for adding controls. Open the document outline to look at the structure of a table object:Ī table has one or more table row controllers. In the object catalog, find the table object.ĭrag the table object to the interface in the storyboard. Go to the Storyboard in the WatchKit App group. You will not need a notification for this project, so you can turn that off. Once the project loads, select Edit>New Target from the drop down menu. ![]() Make new project called SwiftWatchKitTable, with Swift as the language and either Universal or iPhone for the device. Our last lesson in the series will add 5K kilometer splits and summary information using more than one row controller. We’ll learn in the second part how to add and delete data from the table as necessary. In the next lesson we’ll add more data and compute my stats at the splits which we’ll present on a separate screen. In this lesson, we’ll take some of that running data and display the distance and pace achieved for each mile in a table using a single row controller. I was able to collect the data about my run. Back in November I ran the Hot Chocolate 15k in Chicago. In trying to get rid of all those calories of all that pizza I eat, I do run. It’s shrinks to one method the developer need to implement.įor our example, we’re going to use some data about running. It’s a very different experience than the iOS equivalent. ![]() If you are familiar with UITableViewController, you may be delighted to know that WKInterfaceTable is a lot simpler to put together: there are no delegate or data sources involved. There are many instances where tables filled with data at runtime are necessary. In the last post, we looked at scroll views and static tables. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |