2014-02-11 15 views
0

我寫了我的自定義UIAlertview,以允許在某些情況下自動解除。現在,在iOS 7自動解除發生時,導航欄的色調會發生變化。具體根據iOS7轉換指南:UIAlertView的自動dimissal後導航欄的色調變化

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/TransitionGuide.pdf

當警報或動作片出現,iOS裝置7自動變暗的後面視圖的色調的色彩。爲了響應此顏色更改,在其渲染中使用tintColor的自定義視圖子類應該覆蓋tintColorDidChange以在適當時刷新渲染。

任何想法,如果這隻能在自定義UIAlertView中處理。下面是我的自定義UIAlertView中代碼:

#define kStartupFailAlert 203 

#import "RunnerUIAlertView.h" 

@implementation RunnerUIAlertView 

- (id)init { 
    self = [super init]; 

    if (self) { 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAlert) name:kRemoveVisibleAlert object:nil]; 
    } 

    return self; 
} 


- (void)removeAlert { 
    if (self.tag != kStartupFailAlert) { // If not kRunnerStartupFailAlert - as it will be auto dismissed 
     self.delegate = nil; 
     NSInteger aCancelButtonIndex = [self cancelButtonIndex]; 
     [super dismissWithClickedButtonIndex:aCancelButtonIndex animated:NO]; 
    } 
} 


- (void)dealloc { 
    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
} 

@end 

回答

2

得到這個摸索出通過恢復上的應用程序代理窗口的色彩設置。但是,當打開彈出窗口或表單時,它會產生不減弱導航色調顏色的副作用。這似乎是iOS7 SDK的一個問題。

- (void)removeAlert { 
    if (self.tag != kStartupFailAlert) { // If not kRunnerStartupFailAlert - as it will be auto dismissed 
     self.delegate = nil; 
     NSInteger aCancelButtonIndex = [self cancelButtonIndex]; 
     [self dismissWithClickedButtonIndex:aCancelButtonIndex animated:NO]; 

     MyAppDelegate *appDeletgate = [Utilities applicationDelegate]; 
     appDeletgate.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; 
    } 
}