hi iam using uiviewcontroller in which i need to import uisearchcontroller. I am able to import search controller on the screen by defining class type to uisearchcontroller but search bar is missing. When iam adding serach bar on the view as subview app is cashing.
Here is my code to import search container
class ViewController: UISearchController {
override func viewDidLoad() {
super.viewDidLoad()
searchBar.frame = CGRect(x: 50, y: 50, width: self.view.frame.width - 100, height: 200)
self.view.addSubview(searchBar) // crashing at this line..
self.obscuresBackgroundDuringPresentation = true
self.hidesNavigationBarDuringPresentation = false
let searchPlaceholderText = NSLocalizedString("Search Title", comment: "")
self.searchBar.placeholder = searchPlaceholderText
self.searchBar.tintColor = UIColor.black
self.searchBar.barTintColor = UIColor.black
self.searchBar.searchBarStyle = .prominent
self.searchBar.sizeToFit()
self.searchBar.delegate = self
}
}
please help me in bringing uisearchcontainerviewcontroller with variable search bar position and frame.
Thanks in advance