Reputation: 664
I have one view controller with many subviews. When one presses Menu
button, my app should perform some actions. But if there wasn't any "active" actions, my app should close.
override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
guard let type = presses.first?.type else { return }
//...
if falls == true && type == .Menu {
super.pressesBegan(presses, withEvent: event)
}
}
At first time, this code works as should. But if I reopen app and press Menu
button, app closes, however super
function wasn't called.
How should I get rid of that?
Upvotes: 0
Views: 675
Reputation: 664
I did a dirty hack:
Removed super
call:
super.pressesBegan(presses, withEvent: event)
Call suspend
on UIApplication
when I need to close the app
if type == .Menu && falls == true {
UIApplication.sharedApplication().performSelector(Selector("suspend"))
}
Upvotes: 1