2014-10-01 91 views
1

我的应用程序中的一个屏幕显示了本地图像的预览,并且我在左上角有一个操作按钮,用于显示文档交互选项:UIDocumentInteractionController没有考虑到导航栏的色调

- (IBAction)actionButtonTapped:(id)sender { 
    self.interactionController = [UIDocumentInteractionController interactionControllerWithURL:self.attachmentLocalUrl]; 
    self.interactionController.delegate = self; 
    [self.interactionController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES]; 
} 

这种运作良好,因为它显示了一个动作片有一个选项列表,其中包括电子邮件,通过电子邮件发送附件。当我点击电子邮件按钮时,它会显示电子邮件的预览图以及其中的图像。但有一件事情不起作用。我已经定制了我的应用程序的外观,以便导航栏在整个应用程序中具有相同的颜色。下面是我在我的应用程序委托的didFinishLaunchingWithOptions首先运行代码:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 
[UINavigationBar appearance].barTintColor = [UIColor blueColor]; 
[UINavigationBar appearance].tintColor = [UIColor whiteColor]; 
[UINavigationBar appearance].titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]}; 

这非常适用于我自己的视图控制器,而是由UIDocumentInteractionController显示电子邮件预览视图控制器具有蓝色而不是白色的栏按钮的项目。由于其他参数正确应用,特别是导航栏的蓝色背景,“取消”和“发送”操作按钮几乎不可见。

我已经尝试在一个简单的项目中重现这一点,但我不能。很显然,我在我的应用程序中执行某些操作来干扰正常的定制。但我无法弄清楚什么。任何想法我可能会调试?

+0

你可以试试这个代码可以帮助全力为您 的http://计算器。COM /问题/ 26177142 /创建-A-粘视图到了-导航栏/ 26177826#26177826 – 2014-10-13 05:08:17

+0

你可以试试这个代码 http://stackoverflow.com/questions/26177142/create-a-sticky - 查看导航栏/ 26177826#26177826 – 2014-10-13 05:09:27

+0

同样的问题。已经注意到这只发生在设备上而不是在模拟器上。 – 2014-12-09 18:25:48

回答

1

你能澄清一下你的意思吗?导航栏上的颜色是在文档选择器还是mfmail聚合器上搞砸了?下面是一些代码,或者虽然,我不得不使用...

如果它是在UIDocumentPicker,称目前前设置此:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) 
{ 
    [[UIBarButtonItem appearance] setTintColor:[UIColor blackColor]]; 
    [[UINavigationBar appearance] setTintColor:[UIColor blackColor]]; 
} 

,然后将其改回您在didPickDocument有颜色和didCancel代表

,如果它是MFMailcomposer控制器上,然后使用此:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) 
{ 
    [controller.navigationBar setTintColor:[UIColor blackColor]]; 
} 

希望这有助于

+1

它是在UIDocumentInteractionController创建的MFMailComposeViewController中,当我在选项菜单中选择“邮件”后。所以我不知道如何获得对该视图控制器的引用,以便强​​制导航栏的色调颜色像你一样。 – Sebastien 2014-10-10 09:32:27

0

我在解决方法中解决了清除自定义之前呈现UIDocumentController,然后还原我的自定义主题viewWillAppear()呈现UIDocumentController的视图控制器。

func launchDocumentController() { 
    UINavigationBar.appearance().titleTextAttributes = nil 
    UINavigationBar.appearance().barTintColor = nil 
    UINavigationBar.appearance().tintColor = nil 
    documentController.presentOptionsMenuFromRect(self.view.frame, inView: self.view, animated: true) 
} 

然后

public override func viewWillAppear(animated: Bool) { 
    super.viewWillAppear(animated) 
    // Restore the reset bar colors 
    Theme.current.customizeAppearance() 
} 

短的OS更新的,我觉得这是最好的回答“你会得到。抱歉。 (当我有机会时,我将提交一个雷达。)

如果您可以直接访问MFMComposeViewController,如上所述设置色调颜色,是一种很好的解决方法。

0

这里是完美的工作对我来说:

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController { 
    UINavigationBar.appearance().barTintColor = Colors.redColor() 
    UINavigationBar.appearance().tintColor = UIColor.white 
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 14, weight: UIFontWeightBold)] 
    return self 
}