我只是试图以编程方式将搜索栏添加到我的UITableView的标题视图中,就像我之前在另一个视图控制器中所做的那样。我已经使所有属性都相同,并且由于某种原因,搜索栏在成为第一个响应者时不断向下移动。
直接从工作视图控制器示例中复制代码。
searchController.searchBar.delegate = self
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
searchController.searchBar.placeholder = "Search by name or phone number"
searchController.searchBar.searchBarStyle = .Minimal
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.barTintColor = UIColor.lightTextColor()
searchController.searchBar.tintColor = UIColor(red: 50/255, green: 225/255, blue: 165/255, alpha: 1)