Iphone - 按返回后使用所选应用程序设置更新视图控制器
我在我的设置应用程序中定义了 2 个字段。 当用户打开应用程序时,设置中定义的 2 个字段将正确显示。如果用户更改设置然后再次打开我的应用程序,这两个字段不会更新。仅当我重新启动调试器时,它们才会正确更新。我将refreshFields 方法添加到viewWillAppear 中。
但是,当我单击手机上的后退按钮然后再次打开应用程序时,不会捕获 viewWillAppear 。 如果我不单击手机上的后退按钮,而是单击应用程序中创建的后退按钮,则一切正常。
总之,我应该在哪里调用refreshFields方法,以便在单击手机上的后退按钮后第二次打开我的应用程序时捕获它们?
谢谢。
I'm defining 2 fields in my settings' application.
When the user opens the application, the 2 fields defined in the settings are shown correctly. If the user changes the settings and then open my application again, the 2 fields aren't updated. They are only correctly updated when I restart the debugger. I added the refreshFields method to the viewWillAppear.
However, viewWillAppear isn't caught when I click on the back button on the phone and then open the application again.
If instead of clicking the back button on the phone, I click on a back button created in my application, then everything works fine.
In conclusion, where should I call the refreshFields method, so that they are caught when my application is opened for the 2nd time after clicking the back button on the phone?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我当前的解决方案是在 viewDidLoad 中添加以下内容:
但是,屏幕会以旧值显示几毫秒,因为 UIApplicationDidBecomeActiveNotification 在屏幕出现后被捕获。
My current solution is adding the following in the viewDidLoad:
However, the screen appears for a few milliseconds with the old values, since the UIApplicationDidBecomeActiveNotification is caught after the screen appears.
尝试查看 UIApplicationDelegate:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIApplicationDelegate
Try looking at UIApplicationDelegate:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIApplicationDelegate