UIApplication
をサブクラス化し、sendEvent
関数のリスナーを設定することができました。ユーザーがキーボードの特定のボタンに触れたときに、どうすれば通知を受け取ることができますか? sendEvent
のタッチ位置を取得できます。この位置を選択した文字に変換できますか?キーボードプレス通知を聞きます
import Foundation
import UIKit
@objc(Scale) class Scale: UIApplication {
override func sendEvent(_ event: UIEvent) {
if event.type != .touches {
super.sendEvent(event)
return
}
if let touches2 = event.allTouches {
for touch in touches2.enumerated() {
if(touch.element.view == ViewController.self().forceLabel){
print("text touched ")
}
if(touch.element.phase == UITouchPhase.began) {
//Stuff
//print("=====================================")
//print (touch.element.view as Any)
print("**********************")
print(touch.element.location(in: touches2.first?.view))
print("**********************")
}
if(touch.element.phase == UITouchPhase.ended) {
//Stuff
print(";")
}
//print(touch.element.phase)
}
if let touch = touches2.first {
}
}
super.sendEvent(event)
}
}
あなたの間違ったキーを返します英語の文章は、期間を分けることなく、ひどく壊れてしまいます。 iOSアプリケーションをサブクラス化することが何を意味するのか分かりません。 –
そのような有用性は、建設的な、非常にうわー。 @ElTomato – LinusGeffarth