Итак, чтобы создать макет tableView программным способом, вам нужно объявить его в ViewController
var autoCompleteTableView: UITableView!
Инициализировать его в ViewDidLoad
autoCompleteTableView = UITableView(frame: .zero) // constraints will set the frame for us later
установить ограничения в ViewDidLoad
NSLayoutConstraint.activate([
autoCompleteTableView.topAnchor.constraint(equalTo: textField.bottomAnchor, constant: 5), //the constant is how many pts below the textField you want the tableView to be
autoCompleteTableView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
autoCompleteTableView.widthAnchor.constraint(equalTo: view.widthAnchor),
autoCompleteTableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
и затем вы можете установить любые свойства tableView, которые вам нужны. помните, ваш V C также должен реализовывать UITableViewDelegate
и UITableViewDataSource