Cover image for Programming iOS 7, 4th Edition

Book description

If you’re grounded in the basics of Objective-C and Xcode, this practical guide takes you through the components you need for building your own iOS apps. With examples from real apps and programming situations, you’ll learn how to create views, manipulate view controllers, and use iOS frameworks for adding features such as audio and video.

Table of Contents

  1. Preface
    1. Versions
    2. Acknowledgments
    3. From the Programming iOS 4 Preface
    4. Conventions Used in This Book
    5. Using Code Examples
    6. Safari® Books Online
    7. How to Contact Us
  2. I. Views
    1. 1. Views
      1. The Window
      2. Experimenting With Views
      3. Subview and Superview
      4. Visibility and Opacity
      5. Frame
      6. Bounds and Center
      7. Transform
      8. Layout
        1. Autoresizing
        2. Autolayout
          1. Constraints
          2. Autoresizing constraints
          3. Creating constraints in code
          4. Visual format
          5. Mistakes with constraints
          6. Intrinsic content size
        3. Constraints in the Nib
          1. Creating a constraint
          2. Viewing and editing constraints
          3. Problems with constraints
        4. Order of Layout Events
        5. Autolayout and View Transforms
    2. 2. Drawing
      1. UIImage and UIImageView
        1. Resizable Images
        2. Image Rendering Mode
      2. Graphics Contexts
      3. UIImage Drawing
      4. CGImage Drawing
      5. Snapshots
      6. CIFilter and CIImage
      7. Drawing a UIView
      8. Graphics Context Settings
      9. Paths and Shapes
      10. Clipping
      11. Gradients
      12. Colors and Patterns
      13. Graphics Context Transforms
      14. Shadows
      15. Erasing
      16. Points and Pixels
      17. Content Mode
    3. 3. Layers
      1. View and Layer
      2. Layers and Sublayers
        1. Manipulating the Layer Hierarchy
        2. Positioning a Sublayer
        3. CAScrollLayer
        4. Layout of Sublayers
      3. Drawing in a Layer
        1. Content Resizing and Positioning
        2. Layers that Draw Themselves
      4. Transforms
        1. Depth
      5. Shadows, Borders, and Masks
      6. Layer Efficiency
      7. Layers and Key–Value Coding
    4. 4. Animation
      1. Drawing, Animation, and Threading
      2. UIImageView and UIImage Animation
      3. View Animation
        1. Block-Based View Animation
        2. View Animation Options
        3. Springing View Animation
        4. Keyframe View Animation
        5. Transitions
      4. Implicit Layer Animation
        1. Animation Transactions
        2. Media Timing Functions
      5. Core Animation
        1. CABasicAnimation and Its Inheritance
        2. Using a CABasicAnimation
        3. Keyframe Animation
        4. Making a Property Animatable
        5. Grouped Animations
        6. Transitions
        7. Animations List
      6. Actions
        1. What an Action Is
        2. Action Search
        3. Hooking Into the Action Search
        4. Nonproperty Actions
      7. Emitter Layers
      8. CIFilter Transitions
      9. UIKit Dynamics
      10. Motion Effects
      11. Animation and Autolayout
    5. 5. Touches
      1. Touch Events and Views
      2. Receiving Touches
      3. Restricting Touches
      4. Interpreting Touches
      5. Gesture Recognizers
        1. Gesture Recognizer Classes
        2. Gesture Recognizer Conflicts
        3. Subclassing Gesture Recognizers
        4. Gesture Recognizer Delegate
        5. Gesture Recognizers in the Nib
      6. Touch Delivery
        1. Hit-Testing
          1. Hit-testing for layers
          2. Hit-testing for drawings
          3. Hit-testing during animation
        2. Initial Touch Event Delivery
        3. Gesture Recognizer and View
        4. Touch Exclusion Logic
        5. Gesture Recognition Logic
        6. Touches and the Responder Chain
  3. II. Interface
    1. 6. View Controllers
      1. View Controller Responsibilities
      2. View Controller Hierarchy
      3. View Controller Creation
      4. How a View Controller Gets Its View
        1. Manual View
        2. Generic Automatic View
        3. View in a Separate Nib
        4. Nib-Instantiated View Controller
        5. Storyboard-Instantiated View Controller
      5. View Resizing and the Status Bar
      6. Rotation
        1. Rotation and Layout Events
        2. Initial Orientation
      7. Presented View Controller
        1. Presenting a View
        2. Communication With a Presented View Controller
        3. Presented View Animation
        4. Presentation Styles
        5. Rotation of a Presented View
        6. Presenting a View in Response to Rotation
      8. Tab Bar Controllers
        1. Tab Bar Items
        2. Configuring a Tab Bar Controller
      9. Navigation Controllers
        1. Bar Button Items
        2. Navigation Items and Toolbar Items
        3. Configuring a Navigation Controller
      10. Custom Transition Animations
        1. Noninteractive Custom Transition Animation
        2. Interactive Custom Transition Animation
        3. Custom Presented View Controller Transition
        4. Transition Coordinator
      11. Page View Controller
      12. Container View Controllers
      13. Storyboards
        1. Segues
        2. Container Views
        3. Unwind Segues
      14. View Controller Lifetime Events
        1. Incoherencies in View Controller Events
        2. Appear and Disappear Events
        3. Manual Event Forwarding to a Child View Controller
      15. View Controller Memory Management
      16. State Restoration
        1. How to Test State Restoration
        2. Participating in State Restoration
        3. Restoration ID, Identifier Path, and Restoration Class
        4. Restoring View Controller State
        5. Restoration Order of Operations
        6. Restoration of Other Objects
        7. Snapshot Suppression
    2. 7. Scroll Views
      1. Creating a Scroll View in Code
      2. Using a Content View
      3. Scroll View in a Nib
      4. Scrolling
        1. Paging
        2. Tiling
      5. Zooming
        1. Zooming Programmatically
        2. Zooming with Detail
      6. Scroll View Delegate
      7. Scroll View Touches
      8. Floating Scroll View Subviews
      9. Scroll View Performance
    3. 8. Table Views and Collection Views
      1. Table View Cells
        1. Built-In Cell Styles
        2. Registering a Cell Class
        3. Custom Cells
          1. Overriding a cell’s subview layout
          2. Adding subviews in code
          3. Designing a cell in a nib
          4. Designing a cell in a storyboard
      2. Table View Data
        1. The Three Big Questions
        2. Reusing Cells
        3. Table View Sections
        4. Section Index
        5. Refreshing Table View Data
        6. Variable Row Heights
      3. Table View Cell Selection
        1. Managing Cell Selection
        2. Responding to Cell Selection
        3. Navigation From a Table View
        4. Cell Choice and Static Tables
      4. Table View Scrolling and Layout
      5. Table View State Restoration
      6. Table View Searching
      7. Table View Editing
        1. Deleting Table Items
        2. Editable Content in Table Items
        3. Inserting Table Items
        4. Rearranging Table Items
        5. Dynamic Table Items
      8. Table View Menus
      9. Collection Views
        1. Collection View Classes
        2. Using a Collection View
        3. Custom Collection View Layouts
        4. Switching Layouts
        5. Collection Views and UIKit Dynamics
    4. 9. Popovers and Split Views
      1. Preparing a Popover
        1. Popover Size
        2. Popover Appearance Customization
      2. Summoning and Dismissing a Popover
        1. Popover Segues
        2. Managing a Popover Controller
        3. Dismissing a Popover
        4. Popovers During Rotation or Backgrounding
      3. Popovers and Presented Views
      4. Automatic Popovers
      5. Split Views
        1. Using a Split View
        2. Split Views in a Storyboard
        3. Other Split View Configurations
    5. 10. Text
      1. Fonts
        1. Fonts and Dynamic Type
        2. Font Descriptors
      2. Attributed Strings
        1. Attributed String Attributes
        2. Making an Attributed String
          1. Tab stops
          2. Text attachments
        3. Modifying and Querying an Attributed String
        4. Measuring and Drawing an Attributed String
      3. Labels
        1. Number of Lines
        2. Wrapping and Truncation
        3. Label Resizing
        4. Customized Label Drawing
      4. Text Fields
        1. Summoning and Dismissing the Keyboard
        2. Keyboard Covers Text Field
          1. Sliding the interface
          2. Text field in a scroll view
        3. Configuring the Keyboard
        4. Text Field Delegate and Control Event Messages
        5. Text Field Menu
      5. Text Views
        1. Text View as Scroll View
        2. Text View and Keyboard
      6. Text Kit
        1. Text Container
        2. Alternative Text Kit Stack Architectures
        3. Layout Manager
        4. Text Kit Without a Text View
    6. 11. Web Views
      1. Web View Content
        1. Loading Web View Content
        2. Designing Web View Content
      2. Paginated Web Views
      3. Web View State Restoration
      4. Communicating with a Web View
    7. 12. Controls and Other Views
      1. UIActivityIndicatorView
      2. UIProgressView
      3. UIPickerView
      4. UISearchBar
      5. UIControl
        1. UISwitch
        2. UIStepper
        3. UIPageControl
        4. UIDatePicker
        5. UISlider
        6. UISegmentedControl
        7. UIButton
        8. Custom Controls
      6. Bars
        1. Bar Position and Bar Metrics
        2. Bar Appearance
        3. UIBarButtonItem
        4. UINavigationBar
        5. UIToolbar
        6. UITabBar
      7. Tint Color
      8. Appearance Proxy
    8. 13. Modal Dialogs
      1. Alert View
      2. Action Sheet
      3. Dialog Alternatives
      4. Local Notifications
      5. Activity View
  4. III. Some Frameworks
    1. 14. Audio
      1. System Sounds
      2. Audio Session
        1. Interruptions
        2. Routing Changes
      3. Audio Player
      4. Remote Control of Your Sound
      5. Playing Sound in the Background
      6. Further Topics in Sound
    2. 15. Video
      1. MPMoviePlayerController
      2. MPMoviePlayerViewController
      3. UIVideoEditorController
      4. Introduction to AV Foundation
        1. Some AV Foundation Building Blocks
        2. Displaying a Movie
        3. Synchronizing Video With Animation
        4. Building Media
        5. Further Exploration of AV Foundation
    3. 16. Music Library
      1. Exploring the Music Library
        1. Querying the Music Library
        2. Persistence and Change in the Music Library
      2. Music Player
      3. MPVolumeView
      4. Playing Songs With AV Foundation
      5. Music Picker
    4. 17. Photo Library and Image Capture
      1. Choosing From the Photo Library
      2. Assets Library Framework
      3. Using the Camera
      4. Customizing the Image Capture Interface
      5. Image Capture With AV Foundation
    5. 18. Address Book
      1. Address Book Database
      2. Address Book Interface
        1. ABPeoplePickerNavigationController
        2. ABPersonViewController
        3. ABNewPersonViewController
        4. ABUnknownPersonViewController
    6. 19. Calendar
      1. Calendar Database
        1. Creating Calendars and Events
        2. Recurrence
        3. Fetching Events
        4. Reminders
        5. Proximity Alarms
      2. Calendar Interface
        1. EKEventViewController
        2. EKEventEditViewController
        3. EKCalendarChooser
    7. 20. Mail and Messages
      1. Mail Message
      2. Text Message
      3. Twitter Post
    8. 21. Maps
      1. Displaying a Map
      2. Annotations
        1. Custom Annotation View
        2. Custom Annotation Class
        3. Other Annotation Features
      3. Overlays
        1. Custom Overlay Class
        2. Custom Overlay Renderer
        3. Other Overlay Features
      4. Map Kit and Current Location
      5. Communicating With the Maps App
      6. Geocoding, Searching, and Directions
        1. Geocoding
        2. Searching
        3. Directions
    9. 22. Sensors
      1. Core Location
        1. Basic Location Determination
        2. Heading
        3. Background Location
          1. Continuous background location
          2. Significant event monitoring
      2. Acceleration and Attitude
        1. Shake Events
        2. Raw Acceleration
        3. Gyroscope
  5. IV. Final Topics
    1. 23. Persistent Storage
      1. The Sandbox
      2. Basic File Operations
      3. Saving and Reading Files
      4. User Defaults
      5. File Sharing
      6. Document Types
      7. Handing Off a Document
      8. Document Architecture
      9. iCloud
      10. XML
      11. SQLite
      12. Core Data
      13. Image File Formats
    2. 24. Basic Networking
      1. HTTP Requests
        1. Simple HTTP Request
        2. Formal HTTP Request
        3. Multiple Tasks
        4. Background Downloads
      2. Background App Refresh
      3. In-App Purchases
      4. Bonjour
    3. 25. Threads
      1. Main Thread
      2. Why Threading Is Hard
      3. Three Ways of Threading
        1. Manual Threads
        2. NSOperation
        3. Grand Central Dispatch
      4. Threads and App Backgrounding
    4. 26. Undo
      1. Undo Manager
        1. Target–Action Undo
        2. Undo Grouping
        3. Invocation Undo
      2. Undo Interface
        1. Shake-To-Edit
        2. Undo Menu
  6. A. Application Lifetime Events
  7. Index
  8. About the Author
  9. Colophon
  10. Copyright