2015-09-18 84 views
3

是否有任何代碼可以使我的應用程序在我按下按鈕時平滑振動。目前我正在使用以下方法。請看看ios中的平滑觸摸

-(IBAction)buttonClicked:(UIButton *)sender 
{ 
    //AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 
    AudioServicesPlayAlertSound (1105); 
    self.view.userInteractionEnabled = NO; 

    [[HelperClass shared]playSound:@"single_click_12"]; 
[HelperClass showBounceAnimatedButton:sender completionBlock:^{ 
    self.view.userInteractionEnabled = YES; 
    selectedIndex =(int) sender.tag; 
    [self performSelector:@selector(pushTheViewToGame) withObject:nil afterDelay:0.6]; 
}]; 

// NSLog(@"Sender Tag :%li",(long)sender.tag); 
} 
+0

http://stackoverflow.com/questions/12966467/are-there-apis-for-custom-vibrations-in-ios? – Larme

+0

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 請在這行代碼,然後嘗試:) –

回答

1

即使設備啓用,設備也不會振動。

1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

我的方法被稱爲在設備運動的測量的特定時間。我必須停止錄音,然後在振動發生後重新開始錄音。

看起來像這樣。

-(void)vibrate { 
    [recorder stop]; 
    AudioServicesPlaySystemSound (kSystemSoundID_Vibrate); 
    [recorder start]; 
    // recorder is an AVRecorder instance. 

}