I am trying to add a search bar (with an IBAction method) to my viewController, but it is not showing up. Am I missing anything?
import UIKit
class SongrequestViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate {
var tableView = UITableView()
var searchBar = UISearchBar()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
tableView = UITableView(frame: CGRect(x: 10, y: 200, width: 370, height:400))
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.dataSource = self
tableView.delegate = self
self.view.addSubview(tableView)
searchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 50))
searchBar.searchBarStyle = UISearchBar.Style.prominent
searchBar.placeholder = "Search for your song here..."
searchBar.sizeToFit()
searchBar.isTranslucent = false
searchBar.delegate = self
self.view.addSubview(searchBar)
}
The tableView is showing up, but not the search bar.