我正在使用 Xcode 4.5 并针对 iOS 5 及更高版本。
我有一个弹出框,允许用户更改底层视图的背景。
点击“按钮”时,需要我点击两次才能看到更改。
我正在使用NSNotification. 我试过委托,但它什么也没做。
任何帮助或提示将不胜感激。
从 viewWillAppear 来看:
    // nav button is for background image selection
    navigationBtn.tag = buttonTag;
    [navigationBtn setBackgroundImage:[UIImage imageNamed:tempImage] forState:UIControlStateNormal];
    if (selectFlag) {
       [navigationBtn addTarget:self action:@selector(BGSelected:) forControlEvents:UIControlEventTouchUpInside];
    } else {
       navigationBtn.adjustsImageWhenHighlighted = NO;
    }
以及选择方法:
- (void)BGSelected:(id)sender { 
    self.bgtag = [sender tag];
    SettingsDAO *settingsDao = [[SettingsDAO alloc] init];
    if ([self.currentView isEqualToString:@"New_Journal"])
    {
       NSLog(@"Update Journals Background");
       [settingsDao updateJournalBackgroundId:self.journalId withBackgroundId:self.bgtag];
    }
    // notification to let EntryView know the background has changed
    [[NSNotificationCenter defaultCenter] postNotificationName:@"aBackgroundChanged"
                                                    object:self];
    [settingsDao release];
}
NSNotification 方法:
- (void)aBackgroundChanged:(NSNotification *)notification {
    [self invalidate];
    [self reloadSettings];
}