2013-07-03 27 views
2

我使用UIAppearance在我的應用程序中設置所有NavigationBar s的backgroundImage。UIPrintInteractionController和UIAppearance的導航欄

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"background.png"] forBarMetrics:UIBarMetricsDefault]; 

與此同時我用UIPrintInteractionController來實現打印功能。

問題是,打印對話框使用全局外觀設置爲其導航欄。 它看起來像這樣:

enter image description here

在此對話框這不是正確的,我想在這裏不使用任何背景圖像,並有一個系統對話框。

我試圖使用 [UINavigationBar appearanceWhenContainedIn:[UIPrintInteractionController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; ,但應用程序崩潰與此消息:UIPrintInteractionController does not conform to the UIAppearanceContainer protocol

第二個想法是將navigationBar的backgroundImage設置爲零,例如當它被初始化時,或者在它被顯示之前(在委託方法中)爲UIPrintInteractionController。但UIPrintInteractionController沒有公開的方法來獲取它的導航欄,而且,它從NSObject繼承。

有沒有辦法擺脫UIPrintInteractionController導航欄中的背景圖像?

+0

使用嘗試:< - 語言:Objective-C的 - > [UINavigationBar的appearanceWhenContainedIn:[UIPopoverController班級],無] –

+0

@ robert.wijas謝謝,它的工作原理。如果您將其作爲答案發布,我會接受它。 – Anastasia

+0

我做到了,但有人將它轉換爲評論。作爲答案再次發帖。 –

回答

2

你可以採取的支持UIAppearance遏制的事實,這控制器在UIPopoverController呈現優點:

[[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] 
+0

試過了,它不起作用:[[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class],nil] setTintColor:[UIColor blueColor]]; –

+0

它爲我工作..謝謝 –