iOS Auto Layout Demystified [NOOK Book]

Overview

Completed Updated for iOS 7 and Xcode 5

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 ...
See more details below
iOS Auto Layout Demystified

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$13.49
BN.com price
(Save 43%)$23.99 List Price

Overview

Completed Updated for iOS 7 and Xcode 5

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
Read More Show Less

Product Details

  • ISBN-13: 9780133750782
  • Publisher: Pearson Education
  • Publication date: 11/11/2013
  • Series: Mobile Programming
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 2
  • Pages: 288
  • Sales rank: 628,101
  • File size: 23 MB
  • Note: This product may take a few minutes to download.

Meet the Author

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.

Read More Show Less

Table of Contents

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

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)