开发者

How to detect when iPhone is moving in X direction?

开发者 https://www.devze.com 2023-01-02 05:01 出处:网络
How do I detect that the iPhone is moving in a particular direction (X-axis)?Can you show s开发者_高级运维ome sample code?You can do it with help of UIAccelerometer and check the movement fo phone in

How do I detect that the iPhone is moving in a particular direction (X-axis)? Can you show s开发者_高级运维ome sample code?


You can do it with help of UIAccelerometer and check the movement fo phone in x-axis by:

 - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)aceler {
        if (sqrt(aceler.x * aceler.x) > 1.5f)
        {
                  //write your code here
        }
    }

Hope this helps.

Thanks,

Madhup

0

精彩评论

暂无评论...
验证码 换一张
取 消