Preface xiiiChapter 1: Gestures and Touches 1 Touches 1Recipe: Adding a Simple Direct Manipulation Interface 5Recipe: Adding Pan Gesture Recognizers 7Recipe: Using Multiple Gesture Recognizers Simultaneously 9Recipe: Constraining Movement 14Recipe: Testing Touches 15Recipe: Testing Against a Bitmap 17Recipe: Drawing Touches Onscreen 20Recipe: Smoothing Drawings 22Recipe: Using Multi-Touch Interaction 26Recipe: Detecting Circles 29Recipe: Creating a Custom Gesture Recognizer 34Recipe: Dragging from a Scroll View 37Recipe: Live Touch Feedback 40Recipe: Adding Menus to Views 45Summary 47 Chapter 2: Building and Using Controls 49 The UIControl Class 49Buttons 53Buttons in Interface Builder 55Recipe: Building Buttons 56Recipe: Animating Button Responses 60Recipe: Adding a Slider with a Custom Thumb 62Recipe: Creating a Twice-Tappable Segmented Control 67Working with Switches and Steppers 70Recipe: Subclassing UIControl 72Recipe: Building a Star Slider 76Recipe: Building a Touch Wheel 79Recipe: Creating a Pull Control 83Recipe: Building a Custom Lock Control 88Recipe: Image Gallery Viewer 93Building Toolbars 96Summary 98 Chapter 3: Alerting the User 101 Talking Directly to Your User through Alerts 101Recipe: Using Blocks with Alerts 105Recipe: Using Variadic Arguments with Alert Views 110Presenting Lists of Options 112"Please Wait": Showing Progress to Your User 115Recipe: Modal Progress Overlays 117Recipe: Custom Modal Alert View 119Recipe: Basic Popovers 124Recipe: Local Notifications 126Alert Indicators 128Recipe: Simple Audio Alerts 129Summary 133 Chapter 4: Assembling Views and Animations 135 View Hierarchies 135Recipe: Recovering a View Hierarchy Tree 137Recipe: Querying Subviews 139Managing Subviews 141Tagging and Retrieving Views 142Recipe: Naming Views by Object Association 143View Geometry 146Recipe: Working with View Frames 150Recipe: Retrieving Transform Information 158Display and Interaction Traits 164UIView Animations 165Recipe: Fading a View In and Out 167Recipe: Swapping Views 168Recipe: Flipping Views 169Recipe: Using Core Animation Transitions 170Recipe: Bouncing Views as They Appear 172Recipe: Key Frame Animations 174Recipe: Image View Animations 176Summary 177 Chapter 5: View Constraints 179 What Are Constraints? 179Constraint Attributes 180The Laws of Constraints 182Constraints and Frames 184Creating Constraints 186Format Strings 189Predicates 194Format String Summary 196Aligning Views and Flexible Sizing 198Constraint Processing 198Managing Constraints 199Recipe: Comparing Constraints 201Recipe: Creating Fixed-Size Constrained Views 204Recipe: Centering Views 209Recipe: Setting Aspect Ratio 210Recipe: Responding to Orientation Changes 212Debugging Your Constraints 214Recipe: Describing Constraints 215Constraint Macros 218Summary 221 Chapter 6: Text Entry 223 Recipe: Dismissing a UITextField Keyboard 224Recipe: Dismissing Text Views with Custom Accessory Views 228Recipe: Adjusting Views Around Keyboards 230Recipe: Creating a Custom Input View 235Recipe: Making Text-Input-Aware Views 240Recipe: Adding Custom Input Views to Nontext Views 243Recipe: Building a Better Text Editor (Part I) 246Recipe: Building a Better Text Editor (Part II) 248Recipe: Text-Entry Filtering 252Recipe: Detecting Text Patterns 255Recipe: Detecting Misspelling in a UITextView 260Searching for Text Strings 262Summary 262 Chapter 7: Working with View Controllers 263 View Controllers 263Developing with Navigation Controllers and Split Views 266Recipe: The Navigation Item Class 271Recipe: Modal Presentation 273Recipe: Building Split View Controllers 278Recipe: Creating Universal Split View/Navigation Apps 283Recipe: Tab Bars 286Remembering Tab State 290Recipe: Page View Controllers 293Recipe: Custom Containers 303Recipe: Segues 309Summary 315 Chapter 8: Common Controllers 317 Image Picker Controller 317Recipe: Selecting Images 319Recipe: Snapping Photos 326Recipe: Recording Video 331Recipe: Playing Video with Media Player 333Recipe: Editing Video 336Recipe: Picking and Editing Video 339Recipe: E-mailing Pictures 341Recipe: Sending a Text Message 344Recipe: Posting Social Updates 347Summary 349 Chapter 9: Creating and Managing Table Views 351 iOS Tables 351Delegation 352Creating Tables 353Recipe: Implementing a Basic Table 356Table View Cells 360Recipe: Creating Checked Table Cells 362Working with Disclosure Accessories 364Recipe: Table Edits 366Recipe: Working with Sections 374Recipe: Searching Through a Table 381Recipe: Adding Pull-to-Refresh to Your Table 387Recipe: Adding Action Rows 390Coding a Custom Group Table 395Recipe: Building a Multiwheel Table 396Using UIDatePicker 400Summary 401 Chapter 10: Collection Views 403 Collection Views Versus Tables 403Establishing Collection Views 405Flow Layouts 407Recipe: Basic Collection View Flows 412Recipe: Custom Cells 416Recipe: Scrolling Horizontal Lists 418Recipe: Introducing Interactive Layout Effects 422Recipe: Scroll Snapping 424Recipe: Creating a Circle Layout 425Recipe: Adding Gestures to Layout 431Recipe: Creating a True Grid Layout 433Recipe: Custom Item Menus 440Summary 442 Chapter 11: Documents and Data Sharing 445 Recipe: Working with Uniform Type Identifiers 445Recipe: Accessing the System Pasteboard 451Recipe: Monitoring the Documents Folder 454Recipe: Activity View Controller 460Recipe: The Quick Look Preview Controller 470Recipe: Using the Document Interaction Controller 473Recipe: Declaring Document Support 480Recipe: Creating URL-Based Services 486Summary 489 Chapter 12: A Taste of Core Data 491 Introducing Core Data 491Entities and Models 492Creating Contexts 494Adding Data 495Querying the Database 498Removing Objects 500Recipe: Using Core Data for a Table Data Source 501Recipe: Search Tables and Core Data 505Recipe: Adding Edits to Core Data Table Views 508Recipe: A Core Data-Powered Collection View 514Summary 519 Chapter 13: Networking Basics 521 Recipe: Checking Your Network Status 521Scanning for Connectivity Changes 524The URL Loading System 526Recipe: Simple Downloads 528Recipe: Downloads with Feedback 533Recipe: Background Transfers 543Recipe: Using JSON Serialization 546Recipe: Converting XML into Trees 549Summary 554 Chapter 14: Device-Specific Development 555 Accessing Basic Device Information 555Adding Device Capability Restrictions 556Recipe: Checking Device Proximity and Battery States 559Recipe: Recovering Additional Device Information 563Core Motion Basics 565Recipe: Using Acceleration to Locate "Up" 566Working with Basic Orientation 568Recipe: Using Acceleration to Move Onscreen Objects 571Recipe: Accelerometer-Based Scroll View 575Recipe: Retrieving and Using Device Attitude 578Detecting Shakes Using Motion Events 579Recipe: Using External Screens 581Tracking Users 587One More Thing: Checking for Available Disk Space 588Summary 589 Chapter 15: Accessibility 591 Accessibility 101 591Enabling Accessibility 593Traits 594Labels 595Hints 596Testing with the Simulator 597Broadcasting Updates 599Testing Accessibility on iOS 599Speech Synthesis 601Dynamic Type 602Summary 604 Appendix A: Objective-C Literals 605 Numbers 605Boxing 606Container Literals 607Subscripting 608Feature Tests 609 Index 611.
The Core iOS Developer's Cookbook