iPhone - 设置包中的加载设置仅在显示/解除多任务栏后更新

时间:2011-04-25 07:32:03

标签: iphone ios4 view themes uiapplicationdelegate

嘿伙计们,我正在尝试设置一个主题,并且可以通过设置应用程序(设置包)进行选择。我有一个主题设置的多值。我的问题是,当我进入设置应用程序,更改主题,并返回到应用程序时,首先不应用“主题”,它只会在我打开/关闭多任务栏后应用。这是我正在处理的事情:

- (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;
    }    
}

我也知道我应该只有两个单独的NIB文件用于主题..所以我有视图加载随机网页,我不想放松它(即使我可以在应用程序之前保存它关闭)。即使它不是两个单独的NIB,这会起作用还是会减慢我的应用程序?我应该继续为每个主题创建多个NIB吗?

感谢您的所有投入!

1 个答案:

答案 0 :(得分:0)

刚刚找到问题的答案,在您激活时强制同步!