[英]Is there any working algorithm to count steps on all iOS devices (with or without M7 chip)?
I want to make an app. 我要制作一个应用。 that count user steps.
计算用户步骤。 So for that I have searched through the google but didn't found anything that could really help me.
因此,为此,我已经搜索了谷歌,但没有发现任何可以真正帮助我的东西。 Although I came to know that by using Accelerometer data we can get the steps and I tried with this code
尽管我知道通过使用加速度计数据我们可以得到这些步骤,但是我尝试使用此代码
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
const float violence = 1.2;
static BOOL beenhere;
BOOL shake = FALSE;
if (beenhere) return;
beenhere = TRUE;
if (acceleration.x > violence || acceleration.x < (-1* violence))
shake = TRUE;
if (acceleration.y > violence || acceleration.y < (-1* violence))
shake = TRUE;
if (acceleration.z > violence || acceleration.z < (-1* violence))
shake = TRUE;
if (shake) { //(shake || length>=1.7)
numSteps=numSteps+1;
self.stepCountLabel.text = [NSString stringWithFormat:@"%d", numSteps];
}
beenhere = false;
}
But i am not getting the expected results. 但是我没有得到预期的结果。 So if anyone out there know a better algorithm or a link that could help me out.
因此,如果有人在那里知道更好的算法或链接可以对我有所帮助。 Plzz share
Plzz分享
请检查CMStepCounter
为iOS 7已弃用的iOS 8,适用于iOS 8+,退房CMPedometer
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.