![]() Since it is a control, you can easily mix other controls on the same interface as the table. It’s shrinks to one method you need to code. It’s a very different experience than the iOS equivalent. You may be delighted to know that WKInterfaceTable is a lot simpler to put together than a UITableViewController: there are no delegate or data sources involved. Instead of a special controller like UITableViewController in iOS, it is a control you place on the interface. If you need to show a list of data on your watch, you will use a dynaimic table view. In the vertical, you are not limited by size as the watch automatically scrolls to accommodate your controls. If you have controls that don’t change, using the storyboard is the best way to have a series of controls. Make the background Medium Green(#008000)Ĭhange the layout from Horizontal to VerticalĪdd a label with the text My Group, a date control and a switch to the group.īuild and Run. If you need to set up true sections, you can add groups as well. ![]() Scroll down a bit and you’ll see your divided sections. Change the labels to Part1, Part2, and Part3.īuild and run. Find the separator object in the object library.ĭrag separators above and below the Button 3 like this:Īdd a label below the separators and one at the very top. To make it look more like a table view, you can add a few decorations to the interface. Unlike iOS, there is no horizontal scroll, only vertical. Scroll views and static table views are the same thing. On the watch, you can just move the digital crown or do a drag up gesture. ![]() In the watch simulator, click and drag up on the black background to see the hidden items. We start with the same controls as before, though we can see the edge of another button. The Interface continues to grow.īuild and run again with the 44mm simulator. Press Command-V three times to makes three more buttons. Select Button 4, press Command-C to copy. On a 42mm watch, the interface fitsĪdd three more buttons to the scene by copy and paste. Change to a 42mm watch face in the simulator. On a 38mm watch the Button 4 slips slightly out of view The scene stretches to include the buttonīuild and run. Put another button, labeled Button 4 under Button 3. Change the button’s label to Button 1ĭrag another 2 buttons, so we run out of room on the scene. ![]() From the object library, drag a button on the WatchKit scene. In the WatchKit app folder, select the Interface.storyboard. Start your watch and phone simulators to get them ready to run. Make a new project using the WatchOS application template iOS App with WatchOS App Name the project SwiftWatchKitTable, with Swift as the language and Universal for the device, clicking off Include Notification Scene. In this lesson we’ll make scrolling behavior in the Apple Watch with tables and scroll views. They are created on the storyboard, while dynamic table views have some code but simplify the process compared to UIKit. In WatchOS’s WatchKit, scroll views and Static table views are the same thing. In iOS’s UIKit we also have the more free-form scroll view. Once again, WatchOS goes for the simple route that we don’t get in iOS. Static table views are very often used as settings pages in applications. Static tables allow for a vertical scroll view with a set of controls. Dynamic table views read data from a collection type and displays it. Table views come in two flavors: static and dynamic. One of the most powerful and important controls on both wearable and mobile devices are table views. ![]()
0 Comments
Leave a Reply. |