logo资料库

watchOS by Tutorials v3.0 swift4.pdf

第1页 / 共535页
第2页 / 共535页
第3页 / 共535页
第4页 / 共535页
第5页 / 共535页
第6页 / 共535页
第7页 / 共535页
第8页 / 共535页
资料共535页,剩余部分请下载后查看
Table of Contents : Extended
Introduction
About this book
Introducing the third edition
What you need
Who this book is for
How to use this book
Book overview
Book source code and forums
Book updates
License
Acknowledgments
About the cover
Chapter 1: Hello, Apple Watch!
Getting started
Hello, World!
Setting label text in code
Emoji!
Casting emoji fortunes
Refreshing the fortune
Where to go from here?
Chapter 2: Designing Great Watch Apps
Glanceable, Actionable, Responsive
API Overview
Interaction considerations
Visual design considerations
Apps in the App Store
Where to go from here?
Chapter 3: Architecture
Exploring the Watch
Introducing WatchKit
WatchKit apps
WatchKit classes
The dock
Notifications
Complications
New in watchOS 4
WatchKit limitations
Where to go from here?
Chapter 4: UI Controls
Getting started
The timer object
Using a label and buttons to control weight
Using a slider object to control doneness
Integrating the timer
Interacting with scrolling
Using the switch to change units
Where to go from here?
Chapter 5: Pickers
Getting started
Picker display styles
Your first picker
A sequence-style picker
Where to go from here?
Chapter 6: Layout
Getting started
Understanding layout in WatchKit
Laying it all out
Collecting metadata
Laying out buttons
Dynamic layouts
Screen Autorotation
Where to go from here?
Chapter 7: Tables
Tables in WatchKit
Getting started
Getting directions
Creating multiple sections
Where to go from here?
Chapter 8: Navigation
Getting around in WatchKit
Getting started
A modally-presented, paged-based palette
Pushing a child controller
Using menus
Where to go from here?
Chapter 9: Digital Crown and Gesture Recognizers
Getting started
Listening to the Digital Crown
Gestures
Where to go from here?
Chapter 10: Snapshot API
Getting started
The Dock
Snapshot API
Working with snapshots
Where to go from here?
Chapter 11: Networking
Getting started
Calling the web service
Getting a table of data
Populating the table
Fetching a chart
Displaying the chart
Where to go from here?
Chapter 12: Animation
Getting started
Animation overview
Animations in practice
Animated images: a paradox?
Above and beyond
Where to go from here?
Chapter 13: CloudKit
Getting started
CloudKit: an aerial view
Watch app vs iOS app
Adding CloudKit to the Watch app
Where to go from here?
Chapter 14: Notifications
Getting started
Creating a custom notification
Where to go from here?
Chapter 15: Complications
A new category of interaction
Getting started
Adding a complication
Complication families
Creating the data source
Including a complication bundle
Launching from a complication
Complication templates
Data providers
Providing a sample template
Timeline entries
Providing a timeline entry
Where to go from here?
Chapter 16: Watch Connectivity
Getting started
Setting up Watch Connectivity
Device-to-device communication
iPhone-to-Watch communication
Watch-to-iPhone communication
Where to go from here?
Chapter 17: Audio Recording
Getting started
Audio playback
Building an audio player
Background audio playback
Recording audio
Where to go from here?
Chapter 18: Interactive Animation with SpriteKit and SceneKit
Getting started
Introducing SpriteKit and SceneKit
Migrating from iOS
Animating a ring chart
SceneKit
Where to go from here?
Chapter 19: Advanced Watch Connectivity
Getting started
User info transfers
Interactive messaging
Where to go from here?
Chapter 20: Advanced Complications
Getting started
Traveling through time
Keeping your data current
Privacy in complications
Where to go from here?
Chapter 21: Handoff Video Playback
Getting started
Playing video
Making custom interface
Handoff
Configuring activity types
User activities
A quick end-to-end Handoff
Handoff state restoration
Stopping the broadcast
Versioning support
Where to go from here?
Chapter 22: Core Motion
Getting started
Core Motion on iPhone
Core Motion on Apple Watch
Using Watch pedometer data
Supplying the app with information
Handling pedometer data
Replacing the starter simulation code
Running the apps on your devices
Starting a new day
Using the historical accelerometer
Where to go from here?
Chapter 23: HealthKit
Getting started
Asking for permission
Creating workout sessions
Saving a workout
Displaying data while working out
Saving the sample data
Handling Pause or Resume
Where to go from here?
Chapter 24: Core Location
Getting started
Coordination
Optimizations
Where to go from here?
Chapter 25: Core Bluetooth
Getting started
What is Core Bluetooth?
watchOS vs iOS
Building the Watch app
Best practices
Where to go from here?
Chapter 26: Localization
Getting started
Internationalizing your app
Language-specific thoughts
Adding a language
Separating text from code
Formatting values
Running a language scheme
Localizing the app
Previewing the localization
Where to go from here?
Chapter 27: Accessibility
Getting started
Assistive technology overview
WatchKit Accessibility API overview
Adding accessibility to your app
Where to go from here?
Conclusion
watchOS by Tutorials watchOS by Tutorials Third Edition Ehab Amer, Scott Atkinson, Soheil Azarpour, Matthew Morey, Ben Morrow, Audrey Tam & Jack Wu Copyright ©2017 Razeware LLC. Notice of Rights All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner. Notice of Liability This book and all corresponding materials (such as source code) are provided on an “as is” basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software. Trademarks All trademarks and registered trademarks appearing in this book are the property of their own respective owners. raywenderlich.com 2
watchOS by Tutorials Dedications "To my supporting parents. And to my love, thank you for always being there for me." — Ehab Amer "To my amazing wife and family, who encourage me to never stop." — Jack Wu "To Kerri, my beautiful and supportive wife, who gave me my Mac and encouraged me to do something different." — Scott Atkinson "To my lovely, always supportive wife Elnaz, our son Kian and my parents." — Soheil Azarpour "To my amazing wife Tricia and my parents - Thanks for always supporting me." — Matthew Morey "For Dad, who has my back, through times think and thin." — Ben Morrow "To my parents and teachers, who set me on the path that led me to the here and now." — Audrey Tam raywenderlich.com 3
watchOS by Tutorials About the authors Ehab Amer is a software developer in Cairo, Egypt. In the day, he leads mobile development teams create cool apps, In his spare time he spends dozens of hours improving his imagination and finger reflexes playing computer games... or at the gym! Scott Atkinson lives in Alexandria, VA with his wife, Kerri, and daughter, Evelyn. In his day job, he is a software developer at Capital One. When not writing software, he spends time rowing on the Potomac river or exploring new restaurants and cooking great food. Soheil Azarpour is an engineer, developer, author, creator, husband and father. He enjoys bicycling, boating and playing the piano. He lives in Merrimack, NH, and creates iOS apps both professionally and independently. Matthew Morey is an engineer, author, hacker, creator and tinkerer. As an active member of the iOS community and CTO at MJD Interactive he has led numerous successful mobile projects worldwide. When not developing apps he enjoys traveling, snowboarding, and surfing. He blogs about technology and business at matthewmorey.com. matthewmorey.com. Ben Morrow delights in discovering the unspoken nature of the world. He'll tell you the surprising bits while on a walk. He produces beauty by drawing out the raw wisdom that exists within each of us. Audrey Tam retired in 2012 from a 25yr career as a computer science academic. Her teaching included many programming languages, as well as UI design and evaluation. Before moving to Australia, she worked on Fortran and PL/1 simulation software at IBM. Audrey now teaches iOS app development to non-programmers. raywenderlich.com 4
watchOS by Tutorials Jack Wu has built dozens of iOS apps and enjoys it very much. Outside of work, Jack enjoys coding on the beach, coding by the pool, and sometimes just having a quick code in the park. About the editors Antonio Bello is a tech editor of this book. Antonio is a veteran code writer who started tapping on keyboards when memory was measured in bytes instead of gigabytes, storage was an optional add-on, and the most used language was BASIC. Today he loves developing iOS apps, writing node.js backends, and he never misses a chance to learn something new. He finds Swift a very expressive language, and still thinks Objective-C is great and unconventional. Chris Belanger is the editor of this book. Chris is the Book Team Lead and Lead Editor for raywenderlich.com. He was a developer for nearly 20 years in various fields from e-health to aerial surveillance to industrial controls. If there are words to wrangle or a paragraph to ponder, he‘s on the case. When he kicks back, you can usually find Chris with guitar in hand, looking for the nearest beach. Twitter: @crispytwit. Soheil Azarpour is the final pass editor of this book. Soheil is an engineer, developer, author, creator, husband and father. He enjoys bicycling, boating and playing the piano. He lives in Merrimack, NH, and creates iOS apps both professionally and independently. raywenderlich.com 5
watchOS by Tutorials Table of Contents: Overview Introduction Chapter 1: Hello, Apple Watch! Chapter 2: Designing Great Watch Apps Chapter 3: Architecture Chapter 4: UI Controls Chapter 5: Pickers Chapter 6: Layout Chapter 7: Tables Chapter 8: Navigation Chapter 9: Digital Crown and Gesture Recognizers Chapter 10: Snapshot API Chapter 11: Networking Chapter 12: Animation Chapter 13: CloudKit Chapter 14: Notifications Chapter 15: Complications Chapter 16: Watch Connectivity Chapter 17: Audio Recording ........................................................... .................................... ........................................ .......................................... ............................................ ..................................... .................................. .......................... ................................ raywenderlich.com ............................................................. .............................. ............... .......................................... ............................................ ................................................ .................................................. .................................................. ........................................... 16 26 45 61 80 100 116 136 156 173 195 216 236 258 280 296 314 331 6
watchOS by Tutorials Chapter 18: Interactive Animation with SpriteKit and SceneKit ........................................................ Chapter 19: Advanced Watch Connectivity ......... ................ Chapter 20: Advanced Complications Chapter 21: Handoff Video Playback .................. ...................................... Chapter 22: Core Motion .......................................... Chapter 23: HealthKit ................................... Chapter 24: Core Location Chapter 25: Core Bluetooth ................................. ...................................... Chapter 26: Localization Chapter 27: Accessibility ...................................... ............................................................ Conclusion 346 371 384 400 421 439 459 479 496 517 535 raywenderlich.com 7
watchOS by Tutorials Table of Contents: Extended Introduction About this book Introducing the third edition What you need Who this book is for How to use this book Book overview Book source code and forums Book updates License Acknowledgments About the cover Chapter 1: Hello, Apple Watch! Getting started Hello, World! Setting label text in code Emoji! Casting emoji fortunes Refreshing the fortune Where to go from here? Chapter 2: Designing Great Watch Apps Glanceable, Actionable, Responsive API Overview Interaction considerations Visual design considerations Apps in the App Store Where to go from here? Chapter 3: Architecture Exploring the Watch ............................................................. .................................................................................... ................................................................ ..................................................................................... ............................................................................. ........................................................................... ...................................................................................... ............................................................ ...................................................................................... ................................................................................................ ............................................................................... ................................................................................... .............................. .................................................................................... ........................................................................................ ..................................................................... ................................................................................................... ........................................................................ ........................................................................ ...................................................................... ............... ................................................... ....................................................................................... ................................................................... ............................................................... ......................................................................... ...................................................................... .......................................... ............................................................................. 16 17 17 18 18 19 19 23 23 24 24 25 26 27 31 34 35 36 39 43 45 46 52 53 55 58 60 61 61 raywenderlich.com 8
分享到:
收藏