2011-07-28 10 views

答えて

3

UIDavumentControllerをUINavigationControllerに配置すると、そのナビゲーションバーの色が自動的に取得されます。これはおそらくルートビューのnavcontrollerです。

あなたはdocumentInteractionControllerViewControllerForPreview方法でこれを行う:

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller 
{ 
    // Use the rootViewController here so that the preview is pushed onto the navbar stack 
    MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    return appDelegate.window.rootViewController; 
} 
2

[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:107.0/256.0 green:145.0/256.0 blue:35.0/256.0 alpha:1.0]];

置き、このコードAppdelegateのdidFinisLaunching方法インチそれは、アプリケーション全体のナビゲーションバーの色を変更します。

+0

これは全体のアプリ –

10

@DOOManics実装のクリーナーバージョン:

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller 
{ 
    return [self navigationController]; 
} 
+0

偉大な答えの色を変更します。.. –

0

あなたがnavigationControllerを使用していない場合、あなたはどこのUIViewControllerのビューに正しい設定を設定することにより、UIDocumentInteractionControllerにナビゲーションバーの色を設定することができますからUIDocumentInteractionControllerを起動します。

ここで、UIViewController viewController1(ここではUIDocumentInteractionControllerを起動しています)と、ストーリーボードのView1を持っているとします。

ストーリーボードを開いた状態で、viewController1の要素のリストからView1をクリックし、右側の「属性インスペクタ」に移動します。 UIDocumentInteractionControllerには、そこに設定されている背景と色合いが後で使用されます。

次に、あなただけ使用することができます。

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller 
{ 
    return self; 
} 

注viewController1の内側に、あなたは異なる特性を持つナビゲーションバーを持っているかもしれないが、これらはUIDocumentInteractionControllerに使用されないこと。

+0

のために働くようではありません!私はios7。あなたが説明したように色合いと背景色を変更しましたが、プレビュービューコントローラーのボタンは青色のままです。 – kritzikratzi

1

このコードを試してみてください。

- (void)openEC:(NSURL*)url { 
[UINavigationBar appearance].tintColor = [UIColor blueColor]; 
docController = [UIDocumentInteractionController interactionControllerWithURL:url]; 
[docController setDelegate:self]; 
[docController presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES]; 

}

- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller { 
[UINavigationBar appearance].tintColor = [UIColor whiteColor]; 

}