开发者

iPhone SDK shake and vibrate

开发者 https://www.devze.com 2022-12-13 20:16 出处:网络
how can use vibrate when iPhone shaking ? here is my code : #pragma mark - - (void)accelerometer:(UIAccelerometer *)acceleromete开发者_C百科r

how can use vibrate when iPhone shaking ? here is my code :

#pragma mark -
- (void)accelerometer:(UIAccelerometer *)acceleromete开发者_C百科r 
        didAccelerate:(UIAcceleration *)acceleration {
   {
        if (acceleration.x > kAccelerationThreshold 
            || acceleration.y > kAccelerationThreshold
            || acceleration.z > kAccelerationThreshold) {


  **//Vibrate it !** 

        }
    }
}


You can do:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

Make sure to add the AudioToolbox framework.

0

精彩评论

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

关注公众号