开发者

iPhone - loading settings from settings bundle will only update after multitask bar is shown/dismissed

开发者 https://www.devze.com 2023-03-01 00:41 出处:网络
Hey guys, I am trying to have a theme set up and be able to be selected via the Settings App (Settings bundle). I have a multivalue set up with the themes. My problem is that when I go to the settings

Hey guys, I am trying to have a theme set up and be able to be selected via the Settings App (Settings bundle). I have a multivalue set up with the themes. My problem is that when I go to the settings app, change the theme, and go back to the application, the "theme" is not applied at first, it will only be applied after I open/close the mulitasking bar. Here is what I am dealing with:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    defaults = [NSUserDefaults standardUserDefaults]; 
    if (![defaults objectForKey:@"UILayout"]) {
        [defaults setObject:@"Bar_Top" forKey:@"UILayout"];
    }
    [defaults synchronize];
    // Override point for customization after application launch.
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}


- (void)applicationDidBecomeActive:(UIApplication *)application
{
    layout = [defaults valueForKey:@"UILayout"];
    if ([layout isEqualToString:@"Bar_Top"]) {
        NSLog(@"Bar_Top");
        self.viewController.menu.hidden = YES;
        self.viewController.targetOnWebPage.hidden = NO;
        self.viewController.timer.hidden = NO;
        self.viewController.label.frame = CGRectMake(48, 0, 230, 15);
        self.viewController.label.hidden = NO;
    } else if ([layout isEqualToString:@"Bar_Bottom"]) {
        NSLog(@"Bar_Bottom");
        self.viewController.menu.hidden = YES;
        self.viewController.targetOnWebPage.hidden = NO;
        self.viewController.timer.hidden = NO;
        self.viewController.label.frame = CGRectMake(48, 100, 230, 15);
        self.viewController.label.hidden = NO;
    } else if ([layout isEqualToString:@"Menu_Button"]) {
        NSLog(@"Menu_Button");
        self.viewController.menu.hidden = NO;
        self.viewController.targetOnWebPage.hidden = YES;
        self.viewController.timer.hidden = YES;
        self.viewController.label.hidden = YES;
    }    
}

I also know that I should just have two separate NIB files for the themes..however I have the view loading a random web page and I don't wish to loose it (even though I could just save it before the app closes). Even though it is not two separate NIBs, will this work or will it slow down my application? Should I go ahead开发者_如何学Go and create multiple NIBs for each theme?

Thanks for all your input!


Just found an answer to your question, force a synchronization when you become active!

0

精彩评论

暂无评论...
验证码 换一张
取 消