Monday, October 18, 2010

Shake feature in iphone


IPhone is known for its fascinating features and shake feature is one of the kind.Iphone has 2 event features as touch and motion.
Lot of apps pertaining to the shake feature has successfully made its place in the app store, due to its effective utilisation.Here are the 3 methods that implements the shake feature:

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event;
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event;
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event;

As an example consider the following:

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{

UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"TEST"
 message:@"Shake feature Implelmented" delegate:nil
cancelButtonTitle:@"Cancel "
otherButtonTitles:@" OK ",nil];
[alert show];
[alert release];
}

The above code snippet does nothing great , rather than displaying an alert notifying the use of Shake feature in iphone

No comments:

Post a Comment