当应用程序在暂停后变为活动状态时如何重新加载视图?
当用户在 iPhone 上的设置中更改 NsuserDefaults 并在暂停后激活我的应用程序时,我想重新加载活动视图。
我该怎么做?
When the user changes NsuserDefaults in settings on the iPhone and activates my app after it being suspended, i want to reload the active view.
How can i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以实现 applicationDidBecomeActive: 方法,或者在任何其他对象中注册
UIApplicationDidBecomeActiveNotification
通知。You could implement the applicationDidBecomeActive: method in your application delegate, or register for the
UIApplicationDidBecomeActiveNotification
notification in any other object.退出挂起时,将调用应用程序委托上的
- (void)applicationWillEnterForeground:(UIApplication*)application
。实现此方法,在其中检查您所涉及的设置是否已更改,找到最顶层的视图控制器并重新加载它的视图。
- (void)applicationWillEnterForeground:(UIApplication*)application
on the App Delegate is invoked when coming out of suspend.Implement this method, in it check if the setting you are about has changed, find your topmost view controller and reload it's view then.