2010-03-08 55 views

回答

0

使用UIAccelerometer。實施UIAccelerometerDelegate協議,並且執行類似

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { 
    UIAccelerationValue threshold = 2.0; 
    if ((fabsf(acceleration.x) > threshold) || (fabsf(acceleration.y) > threshold) || (fabsfacceleration.z) > threshold) { 
    [self advanceRow]; 
    } 
} 

與適當定義 - [YourClass advanceRow]。嘗試使用不同的閾值進行敏感擺動或劇烈搖晃。

還能看到這樣的回答:how to detect and program around shakes for the iphone

2

蘋果的iPhone人機界面指南警惕定義搖晃手勢自己的意思:

避免超載搖晃手勢。 即使你可以在你的應用程序解釋一個 抖動事件作爲搖撤消編程 集,你跑 迷惑用戶的風險,如果他們也 使用搖來執行不同的 行動。

對於如何實際使用搖動iPhone API,這裏有一個similar question