2014-11-02 6 views
0

iOS에서 새로운 언어를 사용하여 키보드 확장자를 테스트하고 있는데 keyPressed 이벤트에 대해 소리를 재생할 수 없으며 지연 시간이 있습니다. 지연 시간은 약 10 초입니다. 키. 어떤 의견이나 제안에 미리iOS 신속한 맞춤 키보드 소리 및 지연 없음

@IBAction func keyPressed(button: UIButton) { 
    var string = button.titleLabel!.text 
    (textDocumentProxy as UIKeyInput).insertText("\(string!)") 
    AudioServicesDisposeSystemSoundID(1104) 
    AudioServicesPlaySystemSound(1104) 
    UIView.animateWithDuration(0.2, animations: { 
     button.transform = CGAffineTransformScale(CGAffineTransformIdentity, 2.0, 2.0) 
     }, completion: {(_) -> Void in 
      button.transform = 
      CGAffineTransformScale(CGAffineTransformIdentity, 1, 1) 
    }) 
} 

감사합니다 ... 당신은 다른 스레드에서 사운드를 재생해야

+0

키를 누를 때마다 시스템 사운드가 왜 사라 집니까? 이것은 매우 비효율적 인 것 같습니다. – lxt

+0

나는 didLoad에서 처리를 시도했지만 동일한 결과를 얻고 있습니다. – jezuz

+0

저는이 코드를 기반으로합니다 : https://www.dropbox.com/s/gfewd0qekxr5u4i/CustomKeyboardFinal.zip?dl=0 – jezuz

답변

0

:

내 코드입니다. 사용자가이 작업을 수행하려면 전체 액세스 권한을 허용해야합니다. 그래서 확실히 당신은 당신은 deinit 방법 AudioServicesDisposeSystemSoundID(1104)를 이동하는 데 필요한 {

0

앞에있는^기호를 추가 오브젝티브 C를 들어 확장

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),  
{ 
    AudioServicesPlaySystemSound(1104); 
});  

의의 Info.plist이를 요청합니다.