gpt4 book ai didi

Swift:UISearchController 不在窗口层次结构中

转载 作者:行者123 更新时间:2023-11-30 13:26:10 25 4
gpt4 key购买 nike

我在 UITableViewController 上添加了一个搜索栏,但每次单击搜索栏时都会收到错误。 View 也变黑了..

警告:尝试在 FindViewController 上呈现 OWSearchController:其 View 不在窗口层次结构中!

enter image description here

我尝试在 viewDidLoadviewDidAppear 中配置 SearchController ,结果是一样的。

class FindViewController: UITableViewController {

var searchController: OWSearchController!

override func viewDidAppear(animated: Bool) {
self.configureSearchController()
}

func configureSearchController() {

// Create the search controller and make it perform the results updating.
searchController = OWSearchController(searchResultsController: self)
searchController.hidesNavigationBarDuringPresentation = false


// Configure the search controller's search bar.
searchController.searchBar.searchBarStyle = .Minimal
searchController.searchBar.placeholder = NSLocalizedString("Search", comment: "")

// Include the search bar within the navigation bar.
navigationItem.titleView = searchController.searchBar
definesPresentationContext = true
}
}

有人可以帮我解决一下这个问题吗?非常感谢

最佳答案

这是我项目中的工作代码副本

func displayContentController(content: DrawingViewController) {
self.addChildViewController(content)
let drawingFrame = AVMakeRectWithAspectRatioInsideRect(imageView.image!.size, imageView.bounds);
content.view.frame = drawingFrame;
imageView.addSubview(content.view); //image view is a self.view child, you may just use self.view?.addSubview(content.view)
//content.drawingView.reset()
content.didMoveToParentViewController(self);
}

func hideContentController(content: DrawingViewController) {
content.willMoveToParentViewController(nil);
content.view.removeFromSuperview();
content.removeFromParentViewController();
}

关于Swift:UISearchController 不在窗口层次结构中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37179699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com