- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有使用 UICollectionView 制作的自定义数字键盘。我在 didSelectItemAt 方法中获取按下的键值。每当调用 didSelectItemAt 方法时,我都希望键盘发出声音。它应该取决于用户的设备设置。
我已经引用了 Apple 开发人员文档,但我无法实现它。医生说:
To enable a custom input or accessory view for input clicks, perform the following two steps: 1. Adopt the UIInputViewAudioFeedback protocol in your input view class. 2. Implement the enableInputClicksWhenVisible delegate method to return true.
我尝试了以下方式:
class CustomUICollectionView: UICollectionView, UIInputViewAudioFeedback {
var enableInputClicksWhenVisible: Bool {
return true
}
}
@IBOutlet weak var numberPad: CustomUICollectionView!<br/>
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
UIDevice.current.playInputClick()
}
最佳答案
UIInputViewAudioFeedback
的 View 类中调用 playInputClick
。UIInputViewAudioFeedback
并调用playInputClick
的类需要是文本字段或 TextView 的事件inputView
。重构您的代码以满足这些要求,点击将起作用。
关于ios - Swift 3 中点击声音实现的自定义数字键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50829513/
menu Home Events Technical Schedule
我试图阻止触发默认 anchor 链接和 onclick 事件。 这是 HTML 代码: Google 我正在尝试使用以下 jQuery 代码阻止任何重定向的发生: $("#mylink").cli
我想在单击父 div 上的任意位置时切换我的 div,除非单击 anchor 元素。因此,例如,如果我单击示例中的第一个文本,我希望它切换,但在我的示例中的第二个文本上,我不希望它切换。 JSFidd
我在通过 jQuery 伪造 anchor 点击时遇到问题:为什么我的thickbox在我第一次点击输入按钮时出现,但第二次或第三次却没有出现? 这是我的代码: Link 当我直接点击链接时,它总是
我已经从 Mootools 切换到 jQuery,因为我认为它有更好的支持。我有这样的 HTML: Opcje Opcje Opcje Opcje Opcje Opcje Opcje JS
我是一名优秀的程序员,十分优秀!