0

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

- (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 吗?

感谢您的输入!

4

1 回答 1

0

刚刚找到您问题的答案,当您变得活跃时强制同步!

于 2011-08-16T18:39:48.333 回答