Ios CMP计步器步进计数不可用

Ios CMP计步器步进计数不可用,ios,objective-c,iphone,core-motion,Ios,Objective C,Iphone,Core Motion,我的代码是: if ([CMPedometer isStepCountingAvailable]) { self.pedometer = [[CMPedometer alloc] init]; } else { NSLog(@"Step counting is not available on this device!"); [SVProgressHUD showErrorWithStatus:@"Step counting is

我的代码是:

if ([CMPedometer isStepCountingAvailable]) {

        self.pedometer = [[CMPedometer alloc] init];
    }
    else {
        NSLog(@"Step counting is not available on this device!");
        [SVProgressHUD showErrorWithStatus:@"Step counting is not available on this device!"];
    }
当我在iOS8和更高版本的设备上运行它时,它会显示:

此设备上没有步数计数


如何使其可用于步数计算?

您的代码是正确的,它会产生预期的结果。iPhone5没有硬件(苹果M7芯片)来跟踪步数,因此无法进行步数计算


您至少需要一部iPhone 5s

iPhone 4s、5和5c没有M7运动传感器协处理器,因此它们不会记录步骤。iPhone 5s、6和6 Plus都有一个运动协处理器。

您正在测试的设备是什么?可以这样向用户显示消息吗?我还计划在我的应用程序中实现同样的功能,只是好奇地想知道谢谢你的答案。我能用计步器计算海拔吗?@Matthias我正在我的iphone5s(也在iphone5c中)中尝试同样的代码但它对我不起作用……是不是因为苹果M7芯片在这些设备上也不可用???@Matthias苹果怎么能制作出这样一个API,而许多设备都不支持它……因为硬件?请告诉我如何使用CMPedometer实现步幅计数,或者是否有其他方法?