【发布时间】:2014-12-29 00:46:48
【问题描述】:
我正在 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)
})
}
提前感谢您的任何意见或建议...
【问题讨论】:
-
为什么每次按键都会消除系统声音?这似乎效率很低..
-
我已经尝试在 didLoad 处处理,但我得到了相同的结果。
标签: ios xcode swift custom-keyboard ios8-extension