我给我的app设置了设置束,home键退出,然后到设置里面更改了我的app的一些首选项,结果再点击进入app的时候却没有更改显示的值。app中现有的方法都没有被调用。
求大神指教,在这种情况下,会调用哪个系统方法啊?

解决方案 »

  1.   

    UiApplacationDelegate 中applicationDidBecomeActive 从新读取你的配置
      

  2.   

    我也找到了一种方法:
    在viewDidLoad中添加以下代码:
    UIApplication *app = [UIApplication sharedApplication];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:app];
    然后实现applicationWillEnterForeground:方法
    - (void) applicationWillEnterForeground: (NSNotification *) notification {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults synchronize];
        // refreshInfo方法是自己编写的,用来重新获取用户的设置信息
        [self refreshInfo];
    }