YOUR FEEDBACK
shirley wrote: nSynergy SharePoint Document management and collaboration software architectures...
Cloud Computing Conference
March 30 - April 1, New York
Register Today and SAVE !..

READ DIGITAL EDITION


SYS-CON.TV

2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
TOP THREE LINKS YOU MUST CLICK ON


Book Excerpt: iPhone in Action
Using the iPhone's accelerometers

This article is based on iPhone in Action, to be published January 2009. It is being reproduced here by permission from Manning Publications. Manning early access books and ebooks are sold exclusively through Manning. Visit the book's page for more information.

The iPhone's accelerometers can provide access to a variety of information about where an iPhone exists in space. By measuring gravity, you can easily discover an iPhone's precise orientation. By measuring movement, you can see how an iPhone is being guided through space. Further, you can build more complex movements into three-dimensional gestures, such as the shake.

Although we usually think about the iPhone's touch screen in reference to input, the accelerometers provide another method that could allow users to make simple adjustments to a program. We can imagine game controls and painting programs both built entirely around the accelerometers.

The Accelerometer and Orientation
The easiest use of the accelerometers is to determine the iPhone's current orientation. The view controller's interfaceOrientation property can be used to determine orientation; however, you can also access that information through the UIDevice object. It can provide more information, as well as real-time access, that isn't available through the view controller.

There are two ways to access the UIDevice information: through properties and through a notification.

The Orientation Property
The easier way to access the UIDevice is to look at its orientation property. You must first access the UIDevice, which you can do by calling a special UIDevice class method, pretty much the same way you access the UIApplication object:

UIDevice *thisDevice = [UIDevice currentDevice];

Once you've done this, look at the orientation property. It will return a constant drawn from UIDeviceOrientation. This looks exactly like the results you can get from a view controller's orientation property except there are two additional values, as shown in Table 1.

Constant

Summary

UIDeviceOrientationPortrait

iPhone is vertical, right side up

UIDeviceOrientationPortraitUpsideDown

iPhone is vertical, upside down

UIDeviceOrientationLandscapeLeft

iPhone is horizontal, tilted left

UIDeviceOrientationLandscapeRight

iPhone is horizontal, tilted right

UIDeviceOrientationFaceUp

iPhone is lying on its back

UIDeviceOrientationFaceDown

iPhone is lying on its screen

Table 1: UIDeviceOrientation lists six values for a device's orientation

These additional values show off the first reason that you might want to access the UIDevice object rather than examining orientation using a view controller.

The Orientation Notification
The UIDevice class can also give instant access to an orientation change when it occurs. This is done through a notification and is detailed in Listing 1.

As shown, this is a two-step process. First alert the iPhone that you're ready to start listening for notification that the iPhone has changed its orientation (#1). This is one of a pair of UIDevice methods, the other of which is endGeneratingDeviceOrientationNotifactions. Generally you should only leave notifications on when you actually need them, as they take up CPU cycles and thus increase your power consumption.

Second, register to receive the UIDeviceOrientationDidChangeNotification messages (#2), our first real-live example of the notification methods. Thereafter, whenever an orientation change notification occurs, your deviceDidRotate: method will be called. Note that you won't actually receive notification of what the new orientation is, simply that the change happened. For more, you'll have to go out and query the orientation property, as normal.

We've now seen the two ways in which an iPhone's orientation can be tracked with the UIDevice object, providing more information and more rapid notification than we received when using the view controller. However, that only touches the surface of what you can do with the iPhone's accelerometers. It's probably the raw data about changes in three-dimensional space that you really want to access.

About Christopher Allen
Christopher Allen is one of the leaders of the iPhone developer community. He is the host of iPhoneWebDev.com, which is the largest independent community of iPhone-based web developers, and manages its mailing list. He is also one of the founders of iPhoneDevCamp and oversees its Hackathon, and is co-author of iPhone in Action:Introduction to Web and SDK Development. Christopher is a longtime technologist, and is also a leader in social software and was one of the authors of TLS, the next-generation SSL protocol.

About Shannon Appelcline
Shannon Appelcline is a writer and technologist. He was a participant in Charles River Media's Massively Multiplayer Game Development 2. He has also been published by Chaosium Inc., Issaries Inc., Jones Publishing, Partizan Press, White Wolf Publishing, and Wizards of the Coast. In 2007 he wrote over 350,000 words for professional publication, including books for Mongoose Publishing and Moon Design Publications. He has also written fiction published by Green Knight Publishing and comic books published by Skotos Tech.

WIRELESS BUSINESS & TECHNOLOGY LATEST STORIES . . .
"As many of you know," Steve Jobs tells the Apple worldwide community in a heart-rendingly frank memo, "I have been losing weight throughout 2008. The reason has been a mystery to me and my doctors. A few weeks ago, I decided that getting to the root cause of this and reversing it need...
ShapeWriter simultaneously announced the launch of its text entry products on Windows Mobile, Android, and Windows XP/Vista with its upgrades to WritingPad 1.0 for the iPhone, now called ShapeWriter 2.0. Rather than “hunting and pecking,” ShapeWriter 2.0 allows users to produce an ...
The BlackBerry Technical Seminar took place live in December 3, 2008, but these new breakthrough sessions are now available on demand. Managing and extending applications to your mobile users, overcoming development hurdles, and leveraging mobile technology to create new opportunities ...
Shares in Chinese mobile companies soared this week after China approved the issuance of licenses for next generation (3G) mobile networks. China's state council approved the issuance of the long-awaited licensees, opening the door to some $41 billion in spending for equipment. Competi...
Globaltel Media (GTM) launched the pre-release version of its new application, dubbed Cherple, which allows two-way text communication between online computers and mobile wireless cellular devices. Cherple will officially launch in 2009. Globaltel Media claims Cherple will eventually p...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

Click Here

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE