Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Sensing Orientation

As our first introduction to detecting motion, we create the Orientation application. Orientation won’t be wowing users; it’s simply going to say which of six possible orientations the device is currently in. The Orientation application will detect standing-up, upside-down, left-side, right-side, face-down, and face-up orientations.

Implementation Overview

To create the Orientation application, we build an interface that contains a single label and then code up a method that will execute whenever the orientation changes. For this method to be called, we must register with the NSNotificationCenter to receive notifications when appropriate.

Remember, this isn’t the same as interface rotation and resizing; it doesn’t necessitate a change in the interface, and it can handle upside-down and right-side-up orientations as well.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint