Swift 中的 remoteControlReceivedWithEvent 有超类错误
remoteControlReceivedWithEvent in Swift has superclass error
我正在尝试实现 remoteControlWithEvent(在 Swift、iOS 9 中),但我的 App Delegate 出现错误。
我的 viewController 中有以下代码,一切正常。
try AVAudioSession.sharedInstance().setActive(true)
print("AVAudioSession is Active")
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
self.becomeFirstResponder()
但是,在我的 AppDelegate 中,如果我尝试使用函数 remoteControlWithEvent,
override func remoteControlReceivedWithEvent(event: UIEvent) {
let rc = event.subtype
print("does this work? \(rc.rawValue)")
}
我收到错误,"Method does not override any method from it's superclass"。如果我尝试取消覆盖,我会收到另一个错误...
如果你能帮上忙,请告诉我!
-利亚姆
实际试试这个:
override func remoteControlReceivedWithEvent(event: UIEvent?) {
let rc = event!.subtype
print("does this work? \(rc.rawValue)")
}
我正在尝试实现 remoteControlWithEvent(在 Swift、iOS 9 中),但我的 App Delegate 出现错误。
我的 viewController 中有以下代码,一切正常。
try AVAudioSession.sharedInstance().setActive(true)
print("AVAudioSession is Active")
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
self.becomeFirstResponder()
但是,在我的 AppDelegate 中,如果我尝试使用函数 remoteControlWithEvent,
override func remoteControlReceivedWithEvent(event: UIEvent) {
let rc = event.subtype
print("does this work? \(rc.rawValue)")
}
我收到错误,"Method does not override any method from it's superclass"。如果我尝试取消覆盖,我会收到另一个错误...
如果你能帮上忙,请告诉我!
-利亚姆
实际试试这个:
override func remoteControlReceivedWithEvent(event: UIEvent?) {
let rc = event!.subtype
print("does this work? \(rc.rawValue)")
}