iOS Auto Layout Demystified
Addison-Wesley Educational Publishers Inc (Verlag)
978-0-321-96719-0 (ISBN)
- Titel ist leider vergriffen;
keine Neuauflage - Artikel merken
Auto Layout transforms the way you create iOS user interfaces. As flexible as it is powerful, Auto Layout gives you unprecedented control over your iOS user interfaces. But Auto Layout has a reputation for difficulty. In iOS Auto Layout Demystified, Second Edition, world-renowned iOS developer and author Erica Sadun strips away the confusion, helping you gain Auto Layout mastery the easiest way possible: by example.
Fully updated for iOS 7 and Xcode 5, this tutorial delivers everything Sadun’s guides are famous for: clear explanations, expert tips, proven best practices--and, above all, plenty of code to learn from and reuse.
Step by step, Sadun explains how Auto Layout “thinks,” how it works, where it fits, and why it’s more useful (and simpler) than you ever imagined. She offers practical solutions for a wide variety of real-world iOS development challenges, plus innovative ways to use Auto Layout to build interactive elements, animations, and more.
If you’re an experienced iOS developer, this guide will expand your design possibilities, helping you build apps that are superbly usable and intuitive and stand out even in the most crowded marketplace.
Coverage includes
Mastering Auto Layout’s basic concepts, techniques, and approach
Defining unambiguous, satisfiable constraints that express your layout exactly how you intend
Overcoming obstacles to constraint-based user interface design in Interface Builder
Using visual formatting to express how items are laid out vertically and horizontally
Making visual formats more flexible with metrics dictionaries and layout options
Debugging constraints and deciphering those bewildering Xcode log messages
Using descriptive techniques to uncover and express natural relationships in your design
Applying iOS Auto Layout techniques in Mac OS X apps too
Erica Sadun is the bestselling author, coauthor, and contributor to several dozen books on programming, digital video and photography, and web design, including the widely popular The Core iOS 6 Developer's Cookbook, Fourth Edition. She currently blogs at TUAW.com and has blogged in the past at O'Reilly's Mac Devcenter, Lifehacker, and Ars Technica. In addition to being the author of dozens of iOS-native applications, Erica holds a Ph.D. in computer science from Georgia Tech's Graphics, Visualization, and Usability Center. A geek, a programmer, and an author, she's never met a gadget she didn't love. When not writing, she and her geek husband parent three geeks-in-training, who regard their parents with restrained bemusement when they're not busy rewiring the house or plotting global domination.
Preface xiii
Chapter 1: Introducing Auto Layout 1
Origins 1
Saying “Yes” to Auto Layout 2
Geometric Relationships 3
Content-Driven Layout 5
Prioritized Rules 6
Inspection and Modularization 6
Incremental Adoption 6
Constraints 7
Satisfiability 7
Sufficiency 8
Constraint Attributes 11
About Those Missing Views 12
Underconstrained Missing Views 13
Missing Views with Inconsistent Rules 14
Tracking Missing Views 14
Ambiguous Layout 15
Exercising Ambiguity 16
Visualizing Constraints 17
Intrinsic Content Size 18
Compression Resistance and Content Hugging 20
Image Embellishments 22
Alignment Rectangles 22
Visualizing Alignment Rectangles 24
Alignment Insets 24
Declaring Alignment Rectangles 26
Implementing Alignment Rectangles 27
Exercises 29
Conclusions 30
Chapter 2: Constraints 31
Constraint Types 31
Priorities 33
Conflicting Priorities 33
Enumerated Priorities 34
Content Size Constraints 36
Intrinsic Content Size 36
Content Hugging 36
Compression Resistance 38
Setting Content Size Constraints in Code 39
Setting Content Size Constraints in IB 40
Building Layout Constraints 41
The Layout Constraint Class 42
Constraint Math 42
First and Second Items 43
Creating Layout Constraints 44
Building NSLayoutConstraint Instances 45
Unary Constraints 45
Zero-Item Constraints Are Illegal 46
View Items 47
Constraints, Hierarchies, and Bounds Systems 48
Installing Constraints 50
Removing Constraints 52
Comparing Constraints 54
Matching Constraints 55
Laws of Layout Constraints 57
Exercises 59
Conclusions 59
Chapter 3: Interface Builder Layout 61
Designing in IB 61
Disabling Auto Layout 62
Opting Out of Auto Layout in Code 63
Combining Autosizing with Auto Layout 64
Basic Layout and Auto-Generated Constraints 64
Inferred Constraints 64
Ambiguity Resolution Constraints 67
Size Constraints 69
A Guided Tour of IB Elements 69
Constraint Listings 76
Xcode Labels 78
Adding Xcode Identities 79
Adding Constraints 80
Dragging 81
Pinning and Aligning 83
Previewing Layouts 85
Inspecting Constraints 88
View Size Inspector 90
Frame and Layout Rectangles 91
Other Size Inspector Items 92
The Resolution Menu 92
Updating Frames and Constraints 92
Adding and Resetting Constraints 93
Clearing Constraints 93
Constraints/Resizing Pop-Up Menu 93
Descendants 94
Siblings and Ancestors 95
The Missing Views Problem 95
Balancing Requests 97
Hybrid Layout 100
Building a Nib File for Testing 100
Adding the Nib File in Code 101
Advantages of Hybrid Layout 102
Removing IB-Generated Constraints 104
Exercises 105
Conclusions 108
Chapter 4: Visual Formats 109
Introducing Visual Format Constraints 109
Options 111
Alignment 112
Skipping Options 113
Variable Bindings 113
The Problem with Indirection 113
Indirection Workaround 114
Metrics 115
Real-World Metrics 115
Format String Structure 116
Orientation 116
Retrieving Constraints by Axis 117
View Names 117
Superviews 118
Connections 118
Empty Connections 118
Standard Spacers 119
Numeric Spacers 120
Referencing the Superview 120
Spacing from the Superview 122
Flexible Spaces 122
Parentheses 123
Negative Numbers 124
Priorities 124
Multiple Views 125
View Sizes 126
Format String Components 128
Getting It Wrong 130
NSLog and Visual Formats 131
Constraining to a Superview 132
View Stretching 133
Constraining Size 134
Building Rows or Columns 135
Matching Sizes 136
Why You Cannot Distribute Views 137
How to Pseudo-Distribute Views (Part 1: Equal Centers) 138
Pseudo-Distributing Views (Part 2: Spacer Views) 140
Exercises 143
Conclusions 143
Chapter 5: Debugging Constraints 145
Xcode Feedback 145
Development Feedback 145
Compiler Feedback 146
Runtime 146
Reading Console Logs 147
Autosizing Issues Example 147
Solution: Switch Off Autosizing Translation 148
Auto Layout Conflicts Example 149
Solution: Adjusting Priorities 150
The Nuclear Approach 150
The Balance Approach 151
Tracing Ambiguity 151
Examining Constraint Logs 152
Alignment Constraint Example 152
Standard Spacers Example 153
Equation-Based Constraint Example 153
Complex Equation Example 154
Multiplier and Constant Example 155
A Note About Layout Math 155
Constraint Equation Strings 156
Adding Names 159
Using Nametags 160
Naming Views 161
Describing Views 161
Unexpected Padding Example 164
The Hugged Image Example 165
View Centering Example 166
Retrieving Referencing Constraints 167
Descent Reports 169
Ambiguity Example 170
Expanding on Console Dumps Example 172
Visualizing Constraints 173
Automating Visualization 174
Launch Arguments 175
Internationalization 177
Doubled Strings (iOS/OS X) 177
Flipped Interfaces (OS X) 178
Flipped Interfaces (iOS) 179
Profiling Cocoa Layout 181
Auto Layout Rules of Debugging 183
Exercises 183
Conclusions 184
Chapter 6: Building with Auto Layout 185
Basic Principles of Auto Layout 185
Layout Libraries 186
Building Libraries 187
Planning Interfaces 190
Building for Modularity 191
Updating Constraints 194
Calling Updates and Animating Changes 195
Animating Constraint Changes on OS X 196
Fading Changes 197
Designing for Edge Conditions 198
Building a View Drawer 200
Building the Drawer Layout 203
Managing Layout for Dragged Views 206
Dragged Views 207
Window Boundaries 208
Exercises 211
Conclusions 211
Chapter 7: Layout Solutions 213
Table Cells 213
Auto Layout and Multiple-Height Table Cells 216
Preserving Image Aspect 217
Accordion Sizing 220
Scroll Views 221
Scroll Views and Pure Auto Layout 222
Hybrid Solution 222
Building a Paged Image Scroll View 223
Centering View Groups 226
Custom Multipliers and Random Positions 228
Building Grids 231
Making Room for the Keyboard 233
Inserting Views at Runtime 236
Adding iOS Frame and Constraint Overlays 237
Motion Effects, Dynamic Text, and Containers 238
Exercises 238
Conclusions 238
Appendix A: Answers to Exercises 241
Chapter 1 241
Chapter 2 242
Chapter 3 243
Chapter 4 245
Chapter 5 247
Chapter 6 248
Chapter 7 249
Index 251
Erscheint lt. Verlag | 14.11.2013 |
---|---|
Verlagsort | New Jersey |
Sprache | englisch |
Maße | 181 x 229 mm |
Gewicht | 442 g |
Themenwelt | Informatik ► Programmiersprachen / -werkzeuge ► Mac / Cocoa Programmierung |
Informatik ► Software Entwicklung ► Mobile- / App-Entwicklung | |
Technik ► Nachrichtentechnik | |
ISBN-10 | 0-321-96719-4 / 0321967194 |
ISBN-13 | 978-0-321-96719-0 / 9780321967190 |
Zustand | Neuware |
Haben Sie eine Frage zum Produkt? |
aus dem Bereich