我在UITableViewController上添加了一个搜索栏,但每次单击搜索栏时都会出错。视图也变黑了。
警告:尝试在FindViewController上显示OWSearchController:其视图不在窗口层次结构中!
我尝试在 viewDidLoad 和 viewDidAppear 中配置 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
}
}
有人可以帮我解决它有什么问题吗?非常感谢你
答案 0 :(得分:0)
这是我项目的工作代码副本
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();
}