0
後找錯了,我加入編程UISearchController
爲UIViewController
,當UIViewController
加載一切都很好,但是當我在UISearchController
觸摸UISearchBar
,將其移到底部,它正在尋找錯誤的。我第一次在代碼中添加UI元素。UISearchController被觸摸
override func viewDidLoad() {
super.viewDidLoad()
self.definesPresentationContext = true
searchController = ({
let controllerSearch = UISearchController(searchResultsController: nil)
controllerSearch.searchBar.frame = CGRectMake(0, 20, self.view.frame.size.width, 44)
controllerSearch.delegate = self
controllerSearch.searchBar.delegate = self
controllerSearch.searchBar.searchBarStyle = UISearchBarStyle.Default
controllerSearch.dimsBackgroundDuringPresentation = false
controllerSearch.hidesNavigationBarDuringPresentation = false
controllerSearch.searchResultsUpdater = self
controllerSearch.searchBar.sizeToFit()
self.view.addSubview(controllerSearch.searchBar)
return controllerSearch
})()
}
雖然我做的是控制檯顯示的UISearchController
框架,它顯示了正確的結果(0.0,20.0,320.0,44.0),請幫助我的人。 我仍然嘗試過,但結果是一樣的。
let frame = CGRectMake(0, 20, self.view.frame.size.width, 44)
controllerSearch.searchBar.frame = frame