iOS4.2 이상에서 키보드 틱소리 재생 기능 사용하기
개요
- 커스텀 키보드를 만들고, 터치틱사운드 재생하면,
소리크기가 키보드소리 크기가 아닌 일반소리크기를 따라가서
음악듣던중이나 조용한 곳에서 당황하는 경우가 종종 있었는데요.
iOS4.2 에서 해결책이 제공되었었네요. OTL
-[UIInputViewAudioFeedback enableInputClicksWhenVisible] 구현하고,
-[UIDevice playInputClick] 호출하면, 키보드틱사운드 재생됩니다.
키보드 소리 관련 객체
/* UIInputViewAudioFeedback - 키보드 소리를 재생 가능한지 판별하는 Protocol */
protocol UIInputViewAudioFeedback : NSObjectProtocol {
optional var enableInputClicksWhenVisible: Bool { get } // If YES, an input view will enable playInputClick.
}
/* UIDevice - 키보드 소리를 재생 */
class UIDevice : NSObject {
@availability(iOS, introduced=4.2)
func playInputClick() // Plays a click only if an enabling input view is on-screen and user has enabled input clicks.
}
|
주의사항
UIInputViewAudioFeedback 따르는 UIView의 상속구현체가
-[UIView inputView] 또는 -[UView inputAccessoryView] 에
지정된 UITextInput(UITextView, UITextField)가 firstResponder 의 경우에만 재생됩니다.
그외의 경우에는 무시됩니다. |