
Build watchOS Apps DEVELOP AND DESIGN Mark Goody Maurice Kelly This page intentionally left blank Build watchOS Apps DEVELOP AND DESIGN This page intentionally left blank Build watchOS Apps DEVELOP AND DESIGN Mark Goody Maurice Kelly PEACHPIT PRESS WWW.PEACHPIT.COM Build watchOS Apps: Develop and Design Mark Goody and Maurice Kelly Peachpit Press www.peachpit.com To report errors, please send a note to [email protected]. Peachpit Press is a division of Pearson Education. Copyright © 2016 by Mark Goody and Maurice Kelly Editor: Connie Jeung-Mills Production editors: Maureen Forys and Lisa Brazieal Development editor: Robyn G. Thomas Compositor: Kim Scott, Bumpy Design Technical editor: Stepan Hruda Copyeditor: Scout Festa Proofreader: Liz Welch Indexer: James Minkin Cover design: Mimi Heft Interior Design: Mimi Heft Notice of Rights All rights reserved. No part of this book may be reproduced or transmitted in any form by any means, electronic, mechani- cal, photocopying, recording, or otherwise, without the prior written permission of the publisher. For information on getting permission for reprints and excerpts, contact [email protected]. Notice of Liability The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of the book, neither the author nor Peachpit shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the instructions contained in this book or by the computer software and hardware products described in it. Trademarks Apple, Objective-C, OS X, iOS, watchOS, Swift, CocoaTouch, and Xcode are registered trademarks of Apple Inc., registered in the U.S. and other countries. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Peachpit was aware of a trademark claim, the designations appear as requested by the owner of the trademark. All other product names and services identified throughout this book are used in editorial fashion only and for the benefit of such companies with no intention of infringement of the trademark. No such use, or the use of any trade name, is intended to convey endorsement or other affiliation with this book. ISBN-13: 978-0-13-417517-1 ISBN-10: 0-13-417517-4 9 8 7 6 5 4 3 2 1 Printed and bound in the United States of America To my darling wife, Rebecca, and our sons, Reuben and Joel, who give us so much joy. Thank you for your love, patience, and support as I kept disappearing to “work on the book” at what turned out to be a particularly busy time in our family’s life. The three of you are my world. —Mark Goody I am ever grateful once more to my beautiful wife, Fiona, who showed me so much support in getting through another one of these books, and for giving us our sensitive angel Aoibhínn, and our cheeky little monkey Caoimhe. —Maurice Kelly ACKNOWLEDGMENTS We would like to thank the engineering management chain at our employers, ShopKeep Inc., particularly Joshua Vickery, Duncan Grazier, Jason Ordway, and Miriam Kerbache. They sup- ported this endeavor by giving us the permission and space to work on it, and by giving us an enjoyable and progressive engineering environment to return to. They also gave us access to Stepan Hruda, one of the most awesome engineers we’ve worked with and a fearsome force when it comes to reviewing code as our tech editor. We also can’t forget our fellow iOS engi- neers in ShopKeep: Robert and Team Charlie (Kieran, Wes, Zack, and Jordan) in Belfast, as well as James and Gabe in New York City. You all make us much better developers. Once again, we have had the utmost pleasure in working with Robyn Thomas on this book. This time, we ganged up on Robyn and tried to force the UK/US English matter, but she along with our copyeditor, Scout Festa, held firm. We sympathise greatly with them. This time around, we had a new project editor: Connie Jeung-Mills. We’re very pleased to have had the opportunity to work with Connie and extremely grateful that she was able to wrangle us some more pages when we couldn’t stick to our page budget. Thanks also to Clifford Colby for starting the project off (twice, actually); we miss you in our weekly confer- ence calls, though you still owe Robyn an Apple Watch. vi ACKNOWLEDGMENTS ABOUT THE AUTHORS Mark Goody spends most of his time writing software, concentrating on Apple platforms— though he can be tempted to experiment with most things. He lives just outside Belfast, Northern Ireland, with his wife and two sons. They look after him by making sure he remembers to step away from his computer from time to time. Mark blogs sporadically at marramgrass.org.uk and more reliably tweets as @marramgrass. Maurice Kelly has been engineering software since leaving university in 2001. After spending many years working on server software for mobile telecoms, he took a change of direction to work at the user-facing end by becoming an iOS developer. He has a love for synthesizers and music, and still dreams of owning a Land Rover Defender someday. He lives with his wife and children just outside Dromara, a small village in Northern Ireland. ABOUT THE AUTHORS vii CONTENTS Introduction ........................................................ xiii Welcome to watchOS .................................................xvi PART I Getting Started chapter 1 CREATING A WATCHKIT PROJECT . 3 Lifelong Companions ................................................. 4 Adding Code to Your WatchKit App .................................. 5 Updating the Watch Interface ......................................... 5 Writing Code for the Watch App ....................................... 7 “I’m Sorry, But I Don’t Have a Watch” . 10 What Do You Want to Test? ........................................... 10 Trying Out HelloWrist! ................................................ 14 Wrapping Up ......................................................... 14 chapter 2 ANATOMY OF A WATCHOS APP . 15 Apps and Extensions ................................................. 16 What Is a WatchKit App? .............................................. 16 What Is a WatchKit Extension? . 16 Why Do We Need This Convoluted System? ........................... 18 WatchKit App Project Layout ........................................ 18 Creating WatchKit Apps and Extensions ............................ 19 Using Project Templates . 19 Using Target Templates ............................................... 21 Using Old-School Techniques ......................................... 24 Wrapping Up ......................................................... 24 chapter 3 IMPLEMENTING NAVIGATION . 25 Navigating the Apple Watch ......................................... 26 Navigation Types ..................................................... 26 Page-based Navigation ................................................ 27 Hierarchical Navigation ............................................... 30 The WKInterfaceController ........................................... 31 The Circle of Life ....................................................... 31 Supporting Navigation ................................................ 33 The Context Menu ................................................... 36 And So Much More .................................................. 38 Wrapping Up ......................................................... 38 viii CONTENTS chapter 4 EXploRING ConTROLS . 39 House Rules .......................................................... 40 WatchKit Controls ................................................... 40 Simple Display Controls . 41 Interactive Controls ................................................... 43 Structural Controls .................................................... 45 User Input ............................................................. 56 Wrapping Up ......................................................... 56 PART II Creating Apps chapter 5 DESIGNING YoUR APP’S USER InTERFACE . 59 Thinking About Design .............................................. 60 Meeting the Challenge ............................................... 61 “Phenomenal Cosmic Power, Itty-Bitty Living Space” ................ 61 Tap Targets, Fat Fingers, and Small Screens .......................... 64 Bringing a Little Color ................................................. 64 Be Prepared ............................................................ 65 Gesture and Touch ..................................................... 66 Wrapping Up ......................................................... 66 chapter 6 BUILDING YoUR APP’S USER InTERFACE . 67 Laying Out the User Interface ....................................... 68 Grouping Interface Objects Together ................................. 71 Handling the Different Screen Sizes .................................. 72 Images and Animation ............................................... 74 Content vs. Chrome .................................................... 74 Getting Images onto the Watch ....................................... 74 Displaying Images ..................................................... 75 Controlling Animation ................................................ 76 Picker-Linked Animation .............................................. 80 The Settings Interface ................................................ 82 Accessibility .........................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages50 Page
-
File Size-