问题描述
我想打一个应用程序。那算不算用户的步骤。在这样的情况我已经通过谷歌搜索,但没有发现任何能真正帮助我。虽然我才知道,通过使用加速计数据,我们可以得到的步骤,我试图与这code
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;
}
但我没有得到预期的结果。因此,如果有任何人知道一个更好的算法或链接,可以帮助我。Plzz股份
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
推荐答案
pcated iOS中8请看看 CMStepCounter
为iOS 7,它一直是德$ P $,为iOS 8+,看看 CMPedometer
。
Please check out CMStepCounter
for iOS 7. It has been deprecated in iOS 8, for iOS 8+, check out CMPedometer
.
这篇关于是否有任何工作算法来计算所有的iOS设备(带或不带M7芯片)的步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!