0
AppDelegate.swift
에서 @UIApplicationMain
을 삭제하고 아래와 같이 main.swift
을 작성했지만 프로그램은 여전히 keyPressed
기능을 실행할 수 없습니다. 그러나 모든 keydown을 print("send event2")
실행합니다.신속한 iOS 앱의 주요 이벤트를 차단하는 방법은 무엇입니까?
keyPressed
화재는 어떻게 발생합니까? 이 프로그램에 문제가 있습니까? 내가 '선택'#selector (3 SWIFT)가 될을 수정하고 마지막으로 문제를 해결
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
}
}
"조치 : #selector (의 keyPressed (보낸 사람 :)"대신 " 액션 : 셀렉터 (("keyPressed :")) " – baileymiller2017