我的 UIViewController
类 PlayViewController
uploadScore()
当我从 applicationWillResignActive(application: UIApplication)
中调用此函数 uploadScore()
时,它抛出错误 Use of unresolved Identifier 'uploadScore'
uploadScore()
引用了 PlayViewController
中的对象。
我做错了什么?什么是最好的解决方案? 代码在 swift 中。
最佳答案
如果您的应用委托(delegate)对 View Controller 一无所知,它将无法工作。
为什么不让 View Controller 本身监听通知并做任何它需要做的事情呢?通知名称常量在 UIApplication 类引用中均可用。 App Delegate 中的方法很方便,但并不神奇。任何对象都可以响应该通知。
关于ios - 从 applicationwillresignactive 中调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27724639/