I have the same problem. And studies have not responded. My decision:
1) I used the UITableviewController with SearchController, and when I clicked on the field, I had a problem with the user interface: Extra empty space between SearchBar and Tableview The guys noted that you need to use the searchController with the UIViewcontroller and tableView separately. Therefore i did
2) There was this problem. It is solved as follows:
let searchController = UISearchController(searchResultsController: nil) var tableView:UITableView! override func viewDidLoad() { super.viewDidLoad() loadData() setupTableView() setupSearchController() } private func setupTableView(){ tableView = UITableView(frame: CGRect.zero, style: .plain) **//next 2 very important line of code** tableView.autoresizingMask = UIViewAutoresizing() tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) tableView.dataSource = self tableView.delegate = self tableView.register(LetterBrandCell.self, forCellReuseIdentifier: "brandCell") tableView.tableFooterView = UIView() addConstraints() }
In the method of adding constraints, it is important to be tied to the top and bottom list of LayoutGuides, and not just for viewing:
private func addConstraints(){ NSLayoutConstraint(item: tableView, attribute: .top, relatedBy: .equal, toItem: topLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0).isActive = true NSLayoutConstraint(item: tableView, attribute: .bottom, relatedBy: .equal, toItem: bottomLayoutGuide, attribute: .top, multiplier: 1, constant: 0).isActive = true NSLayoutConstraint(item: view, attribute: .leading, relatedBy: .equal, toItem: tableView, attribute: .leading, multiplier: 1, constant: 0).isActive = true NSLayoutConstraint(item: view, attribute: .trailing, relatedBy: .equal, toItem: tableView, attribute: .trailing, multiplier: 1, constant: 0).isActive = true }
demylia Sep 11 '17 at 8:15 2017-09-11-11:15
source share