我有创建UISearchController' in my UIVIew's
viewDidLoad`的代码。
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.searchBar.delegate = self
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
controller.hidesNavigationBarDuringPresentation = false //prevent search bar from moving
controller.searchBar.placeholder = "Search for song"
self.myTableView.tableHeaderView = controller.searchBar
return controller
})()
关闭完成后,控制台中会立即显示以下警告:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UISearchController: 0x154d39700>)
我不明白我在做什么错。类似的问题并不是我的实际情况(至少我不这么认为)。到底是怎么回事?
viewDidLoad()
。建议a)包括整个VC源清单,以及b)确保错误确实在您认为发生的时间和地点发生。