0
Ich löschte die @UIApplicationMain
in AppDelegate.swift
und schrieb die main.swift
wie unten, aber das Programm kann immer noch nicht keyPressed
Funktion feuern. Aber führt print("send event2")
jeden Keydown aus.Wie abzufangen Schlüsselereignis der schnellen iOS App?
Wie feuern keyPressed
Funktion? Stimmt etwas nicht mit diesem Programm?
import UIKit
import Foundation
class TApplication: UIApplication {
override func sendEvent(_ event: UIEvent!) {
super.sendEvent(event)
}
override var keyCommands: [UIKeyCommand]? {
print("send event2") // this is an example
return [
UIKeyCommand(input: "1", modifierFlags: [], action: Selector(("keyPressed:")), discoverabilityTitle: “1”),
UIKeyCommand(input: "2", modifierFlags: .shift, action: Selector("keyPressed:"), discoverabilityTitle: “2”)]
]
}
func keyPressed(sender: UIKeyCommand) {
print("keypressed event !!!!!!!!") // this is an example
}
}
"Aktion: #selector (keyPressed (Sender :))" statt " action: Selektor (("keyPressed:")) " – baileymiller2017