1
我已經使用此代碼來獲得重力值。但問題是,當我將iPhone保持在桌面上時,它仍顯示0.99的價值。可以有人告訴我原因嗎?代碼是重力計算
sx = acceleration.x * kFilteringFactor + sx * (1.0 - kFilteringFactor);
sy = acceleration.y * kFilteringFactor + sy * (1.0 - kFilteringFactor);
sz = acceleration.z * kFilteringFactor + sz * (1.0 - kFilteringFactor);
float aValue = sqrt(sx*sx+sy*sy+sz*sz);
[gLabel setText:[NSString stringWithFormat:@"%.2f",aValue]];