简体   繁体   English

iPhone 检测到用户向上移动了他们的设备

[英]iPhone detect that user moved up their device

I am working on an app where the user sets something (not important what it is) and then puts the phone down.我正在开发一个应用程序,用户可以在其中设置一些东西(并不重要)然后放下电话。 After a little while, the user will pick the phone up again.片刻之后,用户将再次拿起电话。 I want to detect when the user picked up the phone.我想检测用户何时拿起电话。 I am not very experienced with using the accelerometer.我对使用加速度计不是很有经验。 I tried to use the accelerometer a little bit but I noticed that I would have a problem because I am looking for movement, which is change from one position to another.我尝试稍微使用加速度计,但我注意到我会遇到问题,因为我正在寻找运动,即从一个 position 变为另一个。 If anybody knows how to do this, it would be greatly appreciated.如果有人知道如何执行此操作,将不胜感激。

Thanks,谢谢,

You could try something like this, to fire you action when the accelerometers acceleration equals a value you specify.你可以尝试这样的事情,当加速度计加速度等于你指定的值时触发你的动作。

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
     if(acceleration.y > 1.0f)
     {
         NSLog(@"acceleration > myValue");
     } 
}

This post may help you as well这篇文章也可以帮助你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM