简体   繁体   English

更改UIDocumentInteractionController上的NavigationBar背景

[英]Change NavigationBar background on UIDocumentInteractionController

I have to pass a local PDF file (documents directory) from UIWebView to other apps (iBooks, Facebook Messenger, WhatsApp, ...). 我必须将UIWebView的本地PDF文件(文档目录)传递给其他应用程序(iBooks,Facebook Messenger,WhatsApp等)。

So i use UIDocumentInteractionController: 所以我用UIDocumentInteractionController:

- (IBAction)shareButton:(id)sender
{
    NSURL *url = [NSURL URLWithString:self.webView.request.URL.absoluteString];

    self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
    self.docController.delegate = self;
    [self.docController presentOpenInMenuFromBarButtonItem:sender animated:YES];
}

If i select FB Messenger or WhatsApp it shows a ViewController. 如果我选择FB Messenger或WhatsApp,它将显示一个ViewController。

How can i change the NavigationBar appearance of this VC (background image/color, button tint)? 如何更改此VC的NavigationBar外观(背景图像/颜色,按钮色调)? Default white translucent would be nice. 默认白色半透明会很好。

I set a NavigationBar background image in AppDelegate. 我在AppDelegate中设置了NavigationBar背景图像。

if you use this line then Just remove this line and everything works well. 如果您使用此行,则只需删除此行,一切正常。

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];

As for the Status Bar Style, the simplest way would be to pass self.navigationController as the presenter, instead of self: 对于状态栏样式,最简单的方法是将self.navigationController用作演示者,而不是self:

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

It may be helpful to you 这可能对您有帮助

Try this code: 试试这个代码:

- (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];  

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM