2

我在 Swift 3 中制作了一个带有 tableView 的 App,它的标题中有一个 searchBar。searchBar 也有一个带有 scopeButton 的栏。在 iOS 10 中,searchBar 滑到了 navigationBar 所在的位置,一切正常。然而,在 iOS 11 中,tableView 在变为活动状态时会在 searchBar 下滑动,因此第一个单元格几乎被完全覆盖。当我现在点击一个单元格以移动到另一个视图并返回时,scopeButton 移动到了 searchBar 下方。现在第一个单元格再次可见,但到 searchBar 的距离有点大,当然 scopeButton 完全无法使用。我还将我的项目转换为 Swift 4,但这并没有帮助。我正在使用 Xcode 9 GM 和 iOS 11 GM。这是我的代码:

let searchController = UISearchController(searchResultsController: nil)

override func viewDidLoad() {
    super.viewDidLoad()

    UINavigationBar.appearance().titleTextAttributes = accordFont
    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false
    definesPresentationContext = true
    tableView.tableHeaderView = searchController.searchBar
    searchController.searchBar.barTintColor = UIColor(hue: 0.5, saturation: 0.43, brightness: 0.82, alpha: 1.0)
    searchController.searchBar.placeholder = "Suchen"
    self.navigationController?.navigationBar.barTintColor = UIColor(hue: 0.5, saturation: 0.43, brightness: 0.82, alpha: 1.0)
    searchController.searchBar.setValue("Abbruch", forKey:"_cancelButtonText")
    searchController.searchBar.delegate = self
    searchController.searchBar.scopeButtonTitles = ["Name", "Büro Nr.", "Mobil Nr.", "Abteilung"]
    searchController.searchBar.keyboardAppearance = .dark
}

这就是我点击搜索栏时的样子: Screesnhot

如您所见,第一个单元格几乎被完全覆盖。

这是当我在 searchBar 处于活动状态时单击单元格然后返回 tableView 时发生的情况:屏幕截图

4

0 回答 0