O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic Sensors in iOS

Book Description

What really sets the iPhone apart from laptops and PCs is its use of onboard sensors, including those that are location-enabled. This concise book takes experienced iPhone and Mac developers on a detailed tour of iPhone and iPad hardware by explaining how these sensors work, and what they're capable of doing.

With this book, you'll build sample applications for each sensor, and learn hands-on how to take advantage of the data each sensor produces. You'll gain valuable experience that you can immediately put to work inside your own iOS applications for the iPhone, iPod touch, and iPad. This book helps you focus on:

  • Camera: learn how to take pictures and video, create video thumbnails, customize video, and save media to the photo album
  • Audio: use the media picker controller and access the iPod music library in your own application, and enable your app to record and play sampled audio
  • Accelerometer: write an application that uses this sensor to determine device orientation
  • Magnetometer: learn how this sensor verifies compass headings
  • Core Motion: use this framework to receive motion data from both the accelerometer and the vibrational gyroscope

    This short book is part of a collection that will, along with new material, be compiled into a larger book, iOS Sensor Programming. The other books in this collection are Augmented Reality in iOS, Geolocation in iOS, and iOS Sensor Apps with Arduino.

  • Table of Contents

    1. A Note Regarding Supplemental Files
    2. Preface
      1. Who Should Read This Book?
      2. What You Should Already Know?
      3. What Will You Learn?
      4. What’s In This Book?
      5. Conventions Used in This Book
      6. Using Code Examples
      7. Safari® Books Online
      8. How to Contact Us
      9. Acknowledgments
    3. 1. The Hardware
      1. Available Sensor Hardware
      2. Differences Between iPhone and iPad
        1. Device Orientation and the iPad
          1. Going beyond basic support
      3. Detecting Hardware Differences
        1. Camera Availability
        2. Audio Input Availability
        3. GPS Availability
        4. Magnetometer Availability
      4. Setting Required Hardware Capabilities
        1. Persistent WiFi
        2. Background Modes
    4. 2. Using the Camera
      1. The Hardware
      2. Capturing Stills and Video
      3. Video Thumbnails
        1. Video Thumbnails Using the UIImagePicker
        2. Video Thumbnails Using AVFoundation
      4. Saving Media to the Photo Album
      5. Video Customization
    5. 3. Using Audio
      1. The Hardware
      2. Media Playback
      3. Recording and Playing Audio
        1. Recording Audio
        2. Playing Audio
    6. 4. Using the Accelerometer
      1. About the Accelerometer
      2. Writing an Accelerometer Application
      3. Determining Device Orientation
        1. Determining Device Orientation Directly Using the Accelerometer
        2. Obtaining Notifications when Device Orientation Changes
        3. Which Way Is Up?
        4. Convenience Methods for Orientation
      4. Detecting Shaking
    7. 5. Using the Magnetometer
      1. About the Magnetometer
      2. Writing a Magnetometer Application
        1. Determining the Heading in Landscape Mode
      3. Measuring a Magnetic Field
    8. 6. Using Core Motion
      1. Core Motion
        1. Pulling Motion Data
        2. Pushing Motion Data
      2. Accessing the Gyroscope
      3. Measuring Device Motion
        1. Comparing Device Motion with the Accelerometer
    9. 7. Going Further
      1. The iPhone SDK
      2. Geolocation and Maps
        1. Third-Party SDKs
      3. Speech Recognition
      4. Computer Vision
        1. Augmented Reality
      5. External Accessories
    10. About the Author
    11. Colophon
    12. Copyright