Version 1.0.2, 2012-06-26
Added gyroscope UIRequiredDeviceCapabilities to Info.plist.
(Full Revision History)
Xcode 4.2 or later, iOS 5.0 SDK or later
iPad 2 or iPhone 4 running iOS 5.0 or later
pARk is an application project that demonstrates a how to use Core Motion's true north-referenced attitude API. It contains a UIView subclass, ARView, that displays a live camera feed with places-of-interest overlaid at the appropriate coordinates. The places-of-interest used are some famous parks around the world.
Important Note: If you run the compiled application on a device that does not have a gyroscope, you cannot use device motion data. You cannot effectively run the application on the simulator. You have to test and debug applications on a device.
The project has the following classes and protocol, which (except where noted) have corresponding .h and .m file:
ARView —A UIView subclass that provides an augmented reality view of the specified places-of-interest. It uses AVFoundation to provide a live camera feed. It also uses Core Location to determine the user's location and Core Motion to determine where the user is facing (i.e. the user's attitude). When provided with an NSArray containing objects of type PlaceOfInterest, it computes the location of each place-of-interest relative to the user, and on every frame, it projects this onto the user's screen using the attitude provided by Core Motion. It then renders the UIView contained in each PlaceOfInterest at the projected location.
PlaceOfInterest —A class containing the data necessary to locate and render each place-of-interest (i.e. a UIView and a location).
pARkViewController —A view controller that feeds hard-coded places-of-interest to its ARView in viewDidLoad, starts the ARView in viewWillAppear, and stops the ARView in viewWillDisappear.
pARkAppDelegate —A standard implementation of the UIApplicationDelegate protocol.
See "Motion Events" in Event Handling Guide for iPhone OS explains how to use the Core Motion API. The document also includes links to related Core Motion reference documentation.
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-06-26)