PowerPoint Slideshow about 'The Accelerometer' - afra

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

If you want your interface to adapt to different orientations, such as rotating from portrait to landscape, you’ll have to edit the shouldAutorotateToInterfaceOrientation method in your view controller to be specific about which orientations you want to support.

In the code that follows on the next slide, the supported orientations are Portrait, LandscapeLeft and LandscapeRight.

In the simulator you can change orientations from the Hardware drop down menu.

If you want to compensate for the changes to your interface because of supporting multiple orientations, you can select those UI elements in IB, and in the Autosizing tab of the Inspector panel you can adjust their properties. You can choose which sides of the frame you want anchor the element to (struts), or if you want the element to stretch to fit the new orientation (springs).

The iPhone simulator does not natively support data from the accelerometer, but there are a couple of plug-ins for Xcode that allow your device to send that information to the simulator wirelessly.

The free app, AccSim, is available on the App Store. The files it depends upon (which have to be added to your Xcode project) are available at: http://www.brianhpratt.net/cms/index.php?page=accsim

A more robust app that also shares location and touch event data with the simluator is iSimulate. It’s available on the App Store for $15.99. It has a library which has to be embedded in your Xcode project that is available here: http://www.vimov.com/isimulate/sdk/

The advantage of both of these apps is that you don’t have to install your project on your device to be able to test your code. They also provide a convenient way to make video trailers of your apps that use accelerometer input, like games.