传感器 - 摇一摇

/// 

很简单, 只需要在AppDelegate中写上一下代码, 就可以实现摇一摇功能.

 

#import "AppDelegate.h"

 

@interface AppDelegate ()

 

@end

 

@implementation AppDelegate

 

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    return YES;

}

 

 

/**

 *  开始摇一摇就会调用

 */

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

    NSLog(@"%s",__func__);

}

 

/**

 *  摇晃被取消就会调用

 */

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

    NSLog(@"%s",__func__);

}

 

/**

 *  摇晃结束 就会调用

 */

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

    NSLog(@"%s",__func__);

 

}

 

posted @ 2015-09-24 10:59  guangleijia  阅读(184)  评论(0编辑  收藏  举报