0

iOS で新しい言語の Swift を使用してキーボード拡張機能をテストしていますが、keyPressed イベントのサウンドを再生できず、キーをクリックすると約 10 秒の遅延が発生します。

これは私のコードです:

@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)
    })
}

コメントや提案をお寄せいただきありがとうございます...

4

2 に答える 2

0

メソッドに移動AudioServicesDisposeSystemSoundID(1104)する必要があります。deinit

于 2015-01-19T16:49:08.230 に答える