[英]In App Delegate call method from another class
I have a view which contains scroll view with some subviews (UIViewControllers). 我有一个视图,其中包含滚动视图和一些子视图(UIViewControllers)。 I want to call a method (stop timer) from a class, one of their UIViewControllers, in applicationWillResignActive: method of App Delegate.
我想在ApplicationWillResignActive:App Delegate方法中从一个类(UIViewControllers之一)调用一个方法(停止计时器)。
What's the best way to implement this? 实现这个的最佳方法是什么?
Don't worry about handling that event in your app delegate and passing it on. 不要担心在您的app委托中处理该事件并将其传递。 Just register for a notification in whatever class you're interested in handling the event from:
只需注册您对处理该事件感兴趣的任何课程的通知:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(someMethod:)
name:UIApplicationWillResignActiveNotification
object:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.