标签:
// ios 4 之前 UIAccelerometer
// ios 5 <CoreMotion/CoreMotion.h>
#import "ViewController.h"
//#import <CoreMotion/CoreMotion.h>
@interface ViewController ()<UIAccelerometerDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// UIAccelerometer
// 1. 创建单利对象
UIAccelerometer *accelerpmeter = [UIAccelerometer sharedAccelerometer];
// 2. 设置代理
accelerpmeter.delegate = self;
// 3. 设置采样间隔
accelerpmeter.updateInterval = 1.0 / 20;
}
// 4. 实现代理方法
#pragma mark - UIAccelerometerDelegate
/**
* 只要采集到数据, 就会调用一次(调用频率高)
*
* @param accelerometer 单利对象
* @param acceleration <#acceleration description#>
*/
//- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
//{
// LogRed(@"%f --- %f --- %f ----%f",acceleration.timestamp, acceleration.x, acceleration.y, acceleration.z);
//}
@end
标签:
原文地址:http://www.cnblogs.com/guangleijia/p/4833216.html