【问题标题】:UIDocumentPicker navigation bar buttons are hidden at iOS 11UIDocumentPicker 导航栏按钮在 iOS 11 中隐藏
【发布时间】:2017-11-26 12:21:17
【问题描述】:

我注意到我的 UIDocumentPicker 的导航栏中仅在 iOS 11 中存在问题,完成、取消或编辑按钮是不可见的,当用户触摸它时它会出现,即正常状态下的颜色是白色,即使更改 @ 987654325@, 颜色只在触摸时改变。

【问题讨论】:

  • UINavigationBar.appearance().tintColor = tintColor 必须工作。
  • 我也有同样的问题!按钮不显示,但在点击时正在工作..

标签: swift ios11 uidocumentpickerviewcontroller


【解决方案1】:

由于未知原因,我发现如果您使用 Objective-C 创建 UIDocumentPicker 的子类,并在 viewWillAppear 函数中设置 [UINavigationBar appearance].tintColor = [UIColor black];,并在 viewWillDisappear 中将其重置为您的默认值,则效果很好。

但如果您使用swift 执行相同的步骤,则不会。

【讨论】:

  • 太棒了,你是天才,艾哈迈德的工作就像魅力一样谢谢你:-)
【解决方案2】:

我不太喜欢在viewWillAppearviewWillDisappear 之间设置全局外观。外观 API 应仅在应用程序启动时使用。您可以通过将此代码放入application:didFinishLaunchingWithOptions: 来仅重置UIDocumentPickerViewController 的外观而不进行子类化,并且条形按钮将返回它们原来的蓝色:

if #available(iOS 11.0, *) {
    UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self]).tintColor = nil
}

【讨论】:

  • 它的工作..可以帮助我我在 UIactivity 视图控制器上遇到同样的问题.. 我能做什么。
  • 你能知道目标 c 中的语法是什么吗?
【解决方案3】:

UINavigationBarUIBarButtonItem 使用带有黑色appearance 的CustomDocumentPickerViewController

import UIKit

class CustomDocumentPickerViewController: UIDocumentPickerViewController {

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        UINavigationBar.appearance().tintColor = UIColor.black
        UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.black], for: .normal)
    }

    override func viewWillDisappear(_ animated: Bool) {

        UINavigationBar.appearance().tintColor = UIColor.white // your color
        UIBarButtonItem.appearance().setTitleTextAttributes(nil, for: .normal)
        super.viewWillDisappear(animated)

    }

}

【讨论】:

  • 你能在objective c中使用什么语法吗??
猜你喜欢
  • 1970-01-01
  • 2013-01-13
  • 1970-01-01
  • 2015-11-11
  • 1970-01-01
  • 2012-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多