请教iOS中CMPedometer的用法

#import
@implementation FirstViewController

  • (void)viewDidLoad { [super viewDidLoad]; [CMPedometer isStepCountingAvailable]; CMPedometer *pedonmeter = [[CMPedometer alloc] init]; [pedonmeter startPedometerUpdatesFromDate:localDate withHandler:^(CMPedometerData *pedometerData, NSError *error) { if (error) { NSLog(@"%@",error); } else { NSLog(@"%@",pedometerData.startDate); } }]; }

控制台打印出的信息为:Error Domain=CMErrorDomain Code=104 "The operation couldn’t be completed. (CMErrorDomain error 104.)"

求指导 谢谢!

同样的问题啊 后来怎么解决的 我在ipad2上报错 iphone6上没事

把CMPedometer对象声明为属性

 CMErrorNULL = 100, (空)
 CMErrorDeviceRequiresMovement = 101,(设备禁止移动)
 CMErrorTrueNorthNotAvailable  = 102,(罗盘设备不可用)
 CMErrorUnknown = 103, (未知)
 CMErrorMotionActivityNotAvailable  = 104, (运动不可用)
 CMErrorMotionActivityNotAuthorized = 105, (未授权运动)
 CMErrorMotionActivityNotEntitled   = 106, (不允许运动)
 CMErrorInvalidParameter = 107, (无效参数)
 CMErrorInvalidAction    = 108, (无效运动)
 CMErrorNotAvailable     = 109, (不可用)
 CMErrorNotEntitled      = 110, (不可用)
 CMErrorNotAuthorized    = 111, (未授权)