【发布时间】:2018-03-29 23:13:06
【问题描述】:
我试图在按下主页按钮时调用我的视图控制器内的菜单视图,或者当用户接到电话等时......
我的目标是调用 QuestionViewController 中的函数:toggleMenu()。代码如下:
class QuestionViewController: UIViewController, MFMailComposeViewControllerDelegate {
///////////
func toggleMenu() {
// Show or hide menu
if menuStackView.isHidden == true {
// Show the menu
print("Showing Menu")
// Update labels
questionNumberMenuLabel.text = questionNumberLabel.text
endTimer()
menuStackView.isHidden = false
animateInMenu()
} else {
// Hide the menu
animateOutMenu()
}
}
我确实认为我应该使用 AppDelegate.swift 文件中的以下方法:
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
如果我在正确的轨道上,我需要帮助在此方法中调用 QuestionViewController 类的 toggleMenu() 函数。我该怎么做?
非常感谢!
【问题讨论】:
标签: swift xcode delegates appdelegate