5

我实现了一个 searchController 并添加了 navigationItem。

那是代码:

var searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false

definesPresentationContext = true
searchController.searchResultsUpdater = self
searchController.searchBar.placeholder = NSLocalizedString("Search", comment: "")
searchController.hidesNavigationBarDuringPresentation = true

// Layout
searchController.searchBar.barTintColor = UIColor.groupTableViewBackground
navigationItem.searchController = searchController

当我在 searchBar 中单击以写入内容时,控制台中会出现此警告:

NameOfProject[9238:211033] +[CATransaction synchronize] 在事务中调用 NameOfProject[9238:211033] +[CATransaction synchronize] 在事务中调用 NameOfProject[9238:211033] +[CATransaction synchronize] 在事务中调用 NameOfProject[9238:211033] +[ CATransaction synchronize] 在事务中调用

拜托,有人知道如何解决这个问题吗?

提前致谢!!

4

1 回答 1

2

有一个相关的帖子

这篇文章指出,这种行为可能是 iOS 端的一个错误,因为它也出现在一个仅包含一个 UIViewController 的最小示例中,该示例包含一个 UISearchController 并嵌入在 UINavigationController 中(参见Upholder Of Truth的评论)。

于 2018-07-31T08:49:56.390 回答