2012-11-07 71 views

回答

2

我認爲,你不能量變化時,在後臺運行的應用程序(甚至手動)!!。

但是可以檢測到音量設置改變時應用從使用背景喚醒NSUserDefaultsDidChangeNotification

實施例:

-(void)viewDidAppear:(BOOL)animated{ 

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(defaultsSettingsChanged) name:NSUserDefaultsDidChangeNotification object:nil];  
    } 

- (void)viewDidDisappear:(BOOL)animated{ 

    [[NSNotificationCenter defaultCenter] removeObserver:self]; 

} 

-(void)defaultsSettingsChanged{ 

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 

    if([[defaults stringForKey:@"speech"] isEqualToString:@"0"]) 
    { 
     speech.hidden = YES; 
    } 
} 
相關問題