iPhone计步器
来源:互联网 发布:淘宝短信营销资料 编辑:程序博客网 时间:2024/05/18 07:40
//// ViewController.m#import "ViewController.h"#import <CoreMotion/CoreMotion.h>@interface ViewController ()/** 计步器对象 */@property (nonatomic, strong) CMStepCounter *counter;@property (weak, nonatomic) IBOutlet UILabel *stepLabel;@end@implementation ViewController#pragma mark - 懒加载代码- (CMStepCounter *)counter{ if (_counter == nil) { _counter = [[CMStepCounter alloc] init]; } return _counter;}- (void)viewDidLoad { [super viewDidLoad]; // 1.判断计步器是否可用 if (![CMStepCounter isStepCountingAvailable]) { NSLog(@"计步器不可用"); return; } // 2.开始计步 [self.counter startStepCountingUpdatesToQueue:[NSOperationQueue mainQueue] updateOn:5 withHandler:^(NSInteger numberOfSteps, NSDate *timestamp, NSError *error) { if (error) return; self.stepLabel.text = [NSString stringWithFormat:@"您一共走了%ld步", numberOfSteps]; }];}@end
0 0
- iPhone计步器
- IPhone
- iPhone
- iPhone
- iphone
- iphone
- iphone
- iphone
- iphone
- iPhone
- iphone
- iPhone
- iphone
- iphone
- iPhone
- iphone--------------------------------------
- Iphone
- iphone
- 内存中的堆与栈到底是怎么回事?
- getRecordArray
- 【5】EditText——输入框
- 使用Windows Live Writer离线写csdn博客
- 水木社区上看到的一道概率题
- iPhone计步器
- 自动增长字段
- hdu 1561 The more, The Better 树形dp
- MongoDB的简单操作
- 朴素贝叶斯分类器本质上是线性分类器
- hdu 1050 Moving Tables
- GSON 使用教程
- R语言学习路线和常用数据挖掘包
- The Java™ Tutorials — Generics :Restrictions on Generics 泛型约束