0%

Book Description

If you’re grounded in the basics of Swift, Xcode, and the Cocoa framework, this book provides a structured explanation of all essential real-world iOS app components. Through deep exploration and copious code examples, you’ll learn how to create views, manipulate view controllers, and add features from iOS frameworks.

  • Create, arrange, draw, layer, and animate views that respondto touch
  • Use view controllers to manage multiple screens of interface
  • Master interface classes for scroll views, table views, text,popovers, split views, web views, and controls
  • Dive into frameworks for sound, video, maps, and sensors
  • Access user libraries: music, photos, contacts, and calendar
  • Explore files, networking, and threads

Stay up-to-date on iOS 13 innovations, such as:

  • Symbol images
  • Light and dark mode
  • Sheet presentation
  • Diffable data sources and compositional layout
  • Context menus and previews
  • Window scene delegates and multiple windows on iPad

Want to brush up on the basics? Pick up iOS 13 Programming Fundamentals with Swiftto learn about Swift, Xcode, and Cocoa. Together with Programming iOS 13, you’ll gaina solid, rigorous, and practical understanding of iOS 13 development.

Table of Contents

  1. Preface
    1. The Scope of This Book
    2. What’s Not in This Book
    3. From the Programming iOS 4 Preface
    4. Versions
    5. Acknowledgments
    6. Conventions Used in This Book
    7. Using Code Examples
    8. O’Reilly Online Learning
    9. How to Contact Us
  2. I. Views
    1. 1. Views
      1. Window and Root View
        1. How an App Launches
        2. App Without a Storyboard
        3. Referring to the Window
      2. Experimenting with Views
      3. Subview and Superview
      4. Color
      5. Visibility and Opacity
      6. Frame
      7. Bounds and Center
      8. Transform
      9. Transform3D
      10. Window Coordinates and Screen Coordinates
      11. Trait Collections
        1. Interface Style
        2. Size Classes
        3. Overriding Trait Collections
      12. Layout
        1. Autoresizing
        2. Autolayout and Constraints
        3. Implicit Autoresizing Constraints
        4. Creating Constraints in Code
        5. Constraints as Objects
        6. Margins and Guides
        7. Intrinsic Content Size
        8. Self-Sizing Views
        9. Stack Views
        10. Internationalization
        11. Mistakes with Constraints
      13. Configuring Layout in the Nib
        1. Autoresizing in the Nib
        2. Creating a Constraint
        3. Viewing and Editing Constraints
        4. Problems with Nib Constraints
        5. Varying the Screen Size
        6. Conditional Interface Design
      14. Xcode View Features
        1. View Debugger
        2. Previewing Your Interface
        3. Designable Views and Inspectable Properties
      15. Layout Events
    2. 2. Drawing
      1. Images and Image Views
        1. Image Files
        2. Image Views
        3. Resizable Images
        4. Transparency Masks
        5. Reversible Images
      2. Graphics Contexts
        1. Drawing on Demand
        2. Drawing a UIImage
      3. UIImage Drawing
      4. CGImage Drawing
      5. Snapshots
      6. CIFilter and CIImage
      7. Blur and Vibrancy Views
      8. Drawing a UIView
      9. Graphics Context Commands
        1. Graphics Context Settings
        2. Paths and Shapes
        3. Clipping
        4. Gradients
        5. Colors and Patterns
        6. Graphics Context Transforms
        7. Shadows
        8. Erasing
      10. Points and Pixels
      11. Content Mode
    3. 3. Layers
      1. View and Layer
      2. Layers and Sublayers
        1. Manipulating the Layer Hierarchy
        2. Positioning a Sublayer
        3. CAScrollLayer
      3. Layer and Delegate
      4. Layout of Layers
      5. Drawing in a Layer
        1. Drawing-Related Layer Properties
        2. Content Resizing and Positioning
        3. Layers that Draw Themselves
      6. Transforms
        1. Affine Transforms
        2. 3D Transforms
        3. Depth
      7. Further Layer Features
        1. Shadows
        2. Borders and Rounded Corners
        3. Masks
      8. Layer Efficiency
      9. Layers and Key–Value Coding
    4. 4. Animation
      1. Drawing, Animation, and Threading
      2. Image View and Image Animation
      3. View Animation
        1. A Brief History of View Animation
        2. Property Animator Basics
        3. View Animation Basics
        4. View Animation Configuration
        5. Timing Curves
        6. Canceling a View Animation
        7. Frozen View Animation
        8. Custom Animatable View Properties
        9. Keyframe View Animation
        10. Transitions
      4. Implicit Layer Animation
        1. Animatable Layer Properties
        2. Animation Transactions
        3. Media Timing Functions
      5. Core Animation
        1. CABasicAnimation and Its Inheritance
        2. Using a CABasicAnimation
        3. Springing Animation
        4. Keyframe Animation
        5. Making a Property Animatable
        6. Grouped Animations
        7. Freezing an Animation
        8. Transitions
        9. Animations List
      6. Actions
        1. What an Action Is
        2. Action Search
        3. Hooking Into the Action Search
        4. Making a Custom Property Implicitly Animatable
        5. Nonproperty Actions
      7. Emitter Layers
      8. CIFilter Transitions
      9. UIKit Dynamics
        1. The Dynamics Stack
        2. Custom Behaviors
        3. Animator and Behaviors
      10. Motion Effects
      11. Animation and Layout
    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. Gesture Recognizer Delegate
        4. Subclassing Gesture Recognizers
        5. Gesture Recognizers in the Nib
      6. 3D Touch Press Gesture
      7. Touch Delivery
      8. Hit-Testing
        1. Performing Hit-Testing
        2. Hit-Test Munging
        3. Hit-Testing for Layers
        4. Hit-Testing for Drawings
        5. Hit-Testing During Animation
      9. Initial Touch Event Delivery
      10. Gesture Recognizer and View
      11. Touch Exclusion Logic
      12. Gesture Recognition Logic
  3. II. Interface
    1. 6. View Controllers
      1. View Controller Responsibilities
      2. View Controller Hierarchy
        1. Automatic Child View Placement
        2. Manual Child View Placement
        3. Presented View Placement
        4. Ensuring a Coherent Hierarchy
      3. View Controller Creation
      4. How a View Controller Obtains Its View
        1. Manual View
        2. Generic Automatic View
        3. View in a Separate Nib
        4. Summary
      5. How Storyboards Work
        1. How a Storyboard View Controller Nib is Loaded
        2. How a Storyboard View Nib is Loaded
      6. View Resizing
        1. View Size in the Nib Editor
        2. Bars and Underlapping
        3. Resizing and Layout Events
      7. Rotation
        1. Uses of Rotation
        2. Permitting Compensatory Rotation
        3. Initial Orientation
        4. Detecting Rotation
      8. View Controller Manual Layout
        1. Initial Manual Layout
        2. Manual Layout During Rotation
      9. Presented View Controller
        1. Presentation and Dismissal
        2. Configuring a Presentation
        3. Communication with a Presented View Controller
        4. Adaptive Presentation
        5. Presentation, Rotation, and the Status Bar
      10. Tab Bar Controller
        1. Tab Bar Items
        2. Configuring a Tab Bar Controller
      11. Navigation Controller
        1. Bar Button Items
        2. Navigation Items and Toolbar Items
        3. Configuring a Navigation Controller
      12. Custom Transition
        1. Noninteractive Custom Transition Animation
        2. Interactive Custom Transition Animation
        3. Custom Presented View Controller Transition
        4. Transition Coordinator
      13. Page View Controller
        1. Preparing a Page View Controller
        2. Page View Controller Navigation
        3. Other Page View Controller Configurations
      14. Container View Controllers
        1. Adding and Removing Children
        2. Status Bar, Traits, and Resizing
      15. Previews and Context Menus
      16. Storyboards
        1. Triggered Segues
        2. Container Views and Embed Segues
        3. Storyboard References
        4. Unwind Segues
      17. View Controller Lifetime Events
        1. Order of Events
        2. Appear and Disappear Events
        3. Event Forwarding to a Child View Controller
      18. View Controller Memory Management
        1. Lazy Loading
        2. NSCache, NSPurgeableData, and Memory-Mapping
        3. Background Memory Usage
    2. 7. Scroll Views
      1. Content Size
      2. Creating a Scroll View in Code
        1. Manual Content Size
        2. Automatic Content Size with Autolayout
      3. Scroll View Layout Guides
      4. Using a Content View
      5. Scroll View in a Nib
      6. Content Inset
      7. Scrolling
        1. Scrolling in Code
        2. Paging
        3. Tiling
      8. Zooming
        1. Zooming Programmatically
        2. Zooming with Detail
      9. Scroll View Delegate
      10. Scroll View Touches
      11. Floating Scroll View Subviews
      12. Scroll View Performance
    3. 8. Table Views and Collection Views
      1. Table View Controller
      2. Table View Cells
        1. Built-In Cell Styles
        2. Registering a Cell Class
        3. Custom Cells
      3. Table View Data
        1. The Three Big Questions
        2. Reusing Cells
      4. Table View Sections
        1. Section Headers and Footers
        2. Table View Section Example
        3. Section Index
      5. Variable Row Heights
        1. Manual Row Height Measurement
        2. Measurement and Layout with Constraints
        3. Estimated Height
        4. Automatic Row Height
      6. Table View Selection
        1. Managing Cell Selection
        2. Responding to Cell Selection
        3. Navigation from a Table View
      7. Table View Scrolling and Layout
      8. Refreshing a Table View
        1. Cell Choice and Static Tables
        2. Direct Access to Cells
        3. Refresh Control
      9. Editing a Table View
        1. Toggling a Table View’s Edit Mode
        2. Edit Mode and Selection
        3. Changing a Table View’s Structure
        4. Deleting a Cell
        5. Deleting Multiple Cells
      10. Table View Diffable Data Source
        1. Populating a Diffable Data Source
        2. Subclassing a Diffable Data Source
        3. Changing a Diffable Data Source
        4. Pros and Cons of the Diffable Data Source
      11. More Table View Editing
        1. Rearranging Cells
        2. Editable Content in Cells
        3. Expandable Cell
      12. Table View Swipe Action Buttons
      13. Table View Menus
      14. Table View Searching
        1. Configuring a Search Controller
        2. Using a Search Controller
      15. Collection Views
      16. Collection View Classes
      17. Flow Layout
      18. Compositional Layout
        1. Size, Count, Spacing, and Insets
        2. Supplementary Items
        3. Multiple Section Layouts
        4. Other Compositional Layout Features
      19. Collection View Diffable Data Source
      20. Basic Cell Manipulation
        1. Selecting Cells
        2. Deleting Cells
        3. Menu Handling
        4. Rearranging Cells
      21. Custom Collection View Layouts
        1. Tweaking a Layout
        2. Collection View Layout Subclass
        3. Decoration Views
      22. Switching Layouts
      23. Collection Views and UIKit Dynamics
    4. 9. iPad Interface
      1. Popovers
        1. Arrow Source and Direction
        2. Popover Size
        3. Popover Appearance
        4. Passthrough Views
        5. Popover Presentation, Dismissal, and Delegate
        6. Adaptive Popovers
        7. Popover Segues
        8. Popover Presenting a View Controller
      2. Split Views
        1. Expanded Split View Controller (iPad)
        2. Collapsed Split View Controller (iPhone)
        3. Expanding Split View Controller (Big iPhone)
        4. Customizing a Split View Controller
        5. Split View Controller in a Storyboard
        6. Setting the Collapsed State
        7. View Controller Message Percolation
      3. iPad Multitasking
      4. Drag and Drop
        1. Drag and Drop Architecture
        2. Basic Drag and Drop
        3. Item Providers
        4. Slow Data Delivery
        5. Additional Delegate Methods
        6. Table Views and Collection Views
        7. Spring Loading
        8. iPhone and Local Drag and Drop
      5. Multiple Windows
        1. The Window Architecture
        2. Scene Creation
        3. Window Creation and Closing
        4. State Saving and Restoration
        5. Further Multiple Window Considerations
    5. 10. Text
      1. Fonts and Font Descriptors
        1. Fonts
        2. Symbol Images and Text
        3. Font Descriptors
        4. Choosing a Font
        5. Adding Fonts
      2. Attributed Strings
        1. Attributed String Attributes
        2. Making an Attributed String
        3. Modifying and Querying an Attributed String
        4. Custom Attributes
        5. Drawing and Measuring an Attributed String
      3. Labels
        1. Number of Lines
        2. Wrapping and Truncation
        3. Fitting Label and Text
        4. Customized Label Drawing
      4. Text Fields
        1. Summoning and Dismissing the Keyboard
        2. Keyboard Covers Text Field
        3. Text Field Delegate and Control Event Messages
        4. Text Field Menu
        5. Drag and Drop
        6. Keyboard and Input Configuration
      5. Text Views
        1. Links, Text Attachments, and Data
        2. Self-Sizing Text View
        3. Text View and Keyboard
      6. Text Kit
        1. Text View and Text Kit
        2. Text Container
        3. Alternative Text Kit Stack Architectures
        4. Layout Manager
        5. Text Kit Without a Text View
    6. 11. Web Views
      1. WKWebView
        1. Web View Content
        2. Tracking Changes in a Web View
        3. Web View Navigation
        4. Communicating with a Web Page
        5. Custom Schemes
        6. Web View Previews and Context Menus
      2. Safari View Controller
      3. Developing Web View Content
    7. 12. Controls and Other Views
      1. UIActivityIndicatorView
      2. UIProgressView
        1. Progress View Alternatives
        2. The Progress Class
      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
        2. Bar Metrics
        3. Bar and Item Appearance
        4. Bar Background and Shadow
        5. Bar Button Items
        6. Navigation Bar
        7. Toolbar
        8. Tab Bar
      7. Tint Color
      8. Appearance Proxy
    8. 13. Modal Dialogs
      1. Alerts and Action Sheets
        1. Alerts
        2. Action Sheets
        3. Alert Alternatives
      2. Quick Actions
      3. Local Notifications
        1. Authorization for Local Notifications
        2. Notification Categories
        3. Scheduling a Local Notification
        4. Hearing About a Local Notification
        5. Grouped Notifications
        6. Managing Notifications
        7. Notification Content Extensions
      4. Today Extensions
      5. Activity Views
        1. Presenting an Activity View
        2. Custom Activities
        3. Action Extensions
        4. Share Extensions
  4. III. Some Frameworks
    1. 14. Audio
      1. System Sounds
      2. Audio Session
        1. Category
        2. Activation and Deactivation
        3. Ducking
        4. Interruptions
        5. Secondary Audio
        6. Routing Changes
      3. Audio Player
      4. Remote Control of Your Sound
      5. Playing Sound in the Background
      6. AVAudioRecorder
      7. AVAudioEngine
      8. MIDI Playback
      9. Text to Speech
      10. Speech to Text
      11. Further Topics in Sound
    2. 15. Video
      1. AVPlayerViewController
        1. Other AVPlayerViewController Properties
        2. Picture-in-Picture
      2. Introducing AV Foundation
        1. Some AV Foundation Classes
        2. Things Take Time
        3. Time Is Measured Oddly
        4. Constructing Media
        5. AVPlayerLayer
        6. Further Exploration of AV Foundation
      3. UIVideoEditorController
    3. 16. Music Library
      1. Music Library Authorization
      2. Exploring the Music Library
        1. Querying the Music Library
        2. Persistence and Change in the Music Library
      3. Music Player
        1. Setting the Queue
        2. Modifying the Queue
        3. Player State
      4. MPVolumeView
      5. Playing Songs with AV Foundation
      6. Media Picker
    4. 17. Photo Library and Camera
      1. Browsing with UIImagePickerController
        1. Image Picker Controller Presentation
        2. Image Picker Controller Delegate
        3. Dealing with Image Picker Controller Results
      2. Photos Framework
        1. Querying the Photo Library
        2. Modifying the Library
        3. Being Notified of Changes
        4. Fetching Images
        5. Editing Images
        6. Photo Editing Extension
      3. Using the Camera
        1. Capture with UIImagePickerController
        2. Capture with AV Foundation
    5. 18. Contacts
      1. Contact Classes
      2. Fetching Contact Information
        1. Fetching a Contact
        2. Repopulating a Contact
        3. Labeled Values
        4. Contact Formatters
      3. Saving Contact Information
      4. Contact Sorting, Groups, and Containers
      5. Contacts Interface
        1. CNContactPickerViewController
        2. CNContactViewController
    6. 19. Calendar
      1. Calendar Database Contents
        1. Calendars
        2. Calendar Items
        3. Calendar Database Changes
      2. Creating Calendars, Events, and Reminders
        1. Events
        2. Alarms
        3. Recurrence
        4. Reminders
        5. Proximity Alarms
      3. Fetching Events and Reminders
      4. Calendar Interface
        1. EKEventViewController
        2. EKEventEditViewController
        3. EKCalendarChooser
    7. 20. Maps
      1. Map Views
        1. Displaying a Region
        2. Scrolling and Zooming
        3. Other Map View Customizations
        4. Map Images
      2. Annotations
        1. Customizing an MKMarkerAnnotationView
        2. Changing the Annotation View Class
        3. Custom Annotation View Class
        4. Custom Annotation Class
        5. Annotation View Hiding and Clustering
        6. 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
    8. 21. Sensors
      1. Core Location
        1. Location Manager and Delegate
        2. Location Services Authorization
        3. Location Tracking
        4. Where Am I?
        5. Continuous Background Location
        6. Location Monitoring
        7. Heading
      2. Acceleration, Attitude, and Activity
        1. Shake Events
        2. Using Core Motion
        3. Raw Acceleration
        4. Gyroscope
        5. Other Core Motion Data
  5. IV. Final Topics
    1. 22. Persistent Storage
      1. The Sandbox
        1. Standard Directories
        2. Inspecting the Sandbox
        3. Basic File Operations
        4. Saving and Reading Files
        5. File Coordinators
        6. File Wrappers
      2. User Defaults
      3. Simple Sharing and Previewing of Files
        1. File Sharing
        2. Document Types and Receiving a Document
        3. Handing Over a Document
        4. Previewing a Document
        5. Quick Look Previews
      4. Document Architecture
        1. A Basic Document Example
        2. iCloud
        3. Document Browser
        4. Custom Thumbnails
        5. Custom Previews
        6. Document Picker
      5. XML
      6. JSON
        1. Coding Keys
        2. Custom Decoding
      7. SQLite
      8. Core Data
      9. PDFs
      10. Image Files
    2. 23. Basic Networking
      1. HTTP Requests
        1. Obtaining a Session
        2. Session Configuration
        3. Session Tasks
        4. Session Delegate
        5. HTTP Request with Task Completion Function
        6. HTTP Request with Session Delegate
        7. One Session, One Delegate
        8. Delegate Memory Management
        9. Session and Delegate Encapsulation
        10. Downloading Table View Data
        11. Background Session
      2. On-Demand Resources
      3. In-App Purchases
    3. 24. Threads
      1. Main Thread
      2. Background Threads
      3. Why Threading Is Hard
      4. Blocking the Main Thread
      5. Manual Threading
      6. Operation
      7. Grand Central Dispatch
        1. Commonly Used GCD Methods
        2. Synchronous Execution
        3. Dispatch Groups
        4. One-Time Execution
        5. Concurrent Queues
        6. Checking the Queue
      8. App Backgrounding
      9. Background Processing
    4. 25. Undo
      1. Target–Action Undo
      2. Undo Grouping
      3. Functional Undo
      4. Undo Interface
        1. Shake-To-Edit
        2. Built-In Gestures
        3. Undo Menu
    5. A. Lifetime Events
      1. Application States
      2. Delegate Events
      3. Lifetime Scenarios
        1. Major State Changes
        2. Paused Inactivity
        3. Transient Inactivity on the iPad
        4. Multiple Windows
        5. Scene Death in the App Switcher
      4. Lifetime Event Timing
    6. B. Some Useful Utility Functions
      1. Core Graphics Initializers
      2. Center of a CGRect
      3. Adjust a CGSize
      4. Delayed Performance
      5. Dictionary of Views
      6. Constraint Issues
      7. Named Views
      8. Subviews of Given Class
      9. Configure a Value Class at the Point of Use
      10. Downsize a UIImage
    7. C. How Asynchronous Works
  6. Index
44.197.116.176