2011-01-06 38 views
2

我有一個UINavigationController作爲我的UIPopoverController的主視圖。我想改變導航欄和工具欄的顏色色調,但似乎無法使其工作。更改導航欄和工具欄中的導航控制器作爲視圖的色調

任何人都可以指向正確的方向嗎?

這裏是我有代碼不工作的代碼。 哪裏配色方案=的UIColor colorWithRed:0.228綠色:0.307藍:0.492阿爾法:1.000] 下面是從的NSLog語句後的結果: 配色方案= UIDeviceRGBColorSpace 0.228 0.307 0.492 1

self.navController = [[UINavigationController alloc] 
         initWithRootViewController:serversMenu]; 
NSLog(@"Color Scheme = %@", self.appDelegate.colorScheme); 
self.navController.navigationBar.tintColor = self.appDelegate.colorScheme; 
self.navController.toolbar.tintColor = self.appDelegate.colorScheme; 

self.navController.navigationBar.translucent = YES; 
UIPopoverController *poc = [[UIPopoverController alloc] initWithContentViewController:self.navController]; 
poc.delegate = serversMenu; 
serversMenu.mainPopOver = poc; 
[poc release]; 

謝謝,

羅布

+0

你有這方面的解決方案嗎? – 2011-02-15 10:15:34

回答

4

這只是正常:

AboutViewController *avc = [[AboutViewController alloc] init]; 

UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:avc] retain]; 

avc.navigationController.navigationBar.tintColor = [UIColor greyColor]; /* or whatever color you choose */ 
toolbar.tintColor = [UIColor greyColor]; 

依賴於浩W使您選擇創建UIPopoverController

+0

我一定在做錯事。這就是我正在做的,模擬器中的色調沒有改變。 – Rob 2011-01-07 15:43:43

0

這是一個錯誤...這是你的修復...創建UINavigationBar的的子類與此,因爲它是唯一的新方法:

- (void)setTintColor:(UIColor *)tintColor 
{ 
    // Bug workaround. 
    [super setTintColor:[self tintColor]]; 
} 

我要去冒險出現在肢體上,並說這是iOS 4.2.x的PopOver/SplitView更新中的一個錯誤...我說「bug」,因爲我已經把它設置得像你一樣,在4.1之下它按預期工作。現在,在4.2.x下,它最初看起來不錯,但是一旦你在popover中打開masterView,然後旋轉回到雙重分割,masterView的導航欄就是silver(ios默認值),並且不會有大量錘子敲打會獲得masterView導航欄色彩重置爲您的配色方案...

我不完全如何最好把它放在一個錯誤報告的形式,因爲我自己並沒有完全理解它。但它使用工作,我們沒有做任何瘋狂的事情!