我已经子类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