     
     private func createSearchBar() {
         if self.tableView.tableHeaderView == nil {
-            let theSearchBar = UISearchBar(frame: CGRectMake(0, 0, 320, 40))
-            theSearchBar.showsCancelButton = true
-            tableView.tableHeaderView = theSearchBar
+//            let theSearchBar = UISearchBar(frame: CGRectMake(0, 0, 320, 40))
+//            theSearchBar.showsCancelButton = true
+           
             
-            searchController = UISearchDisplayController(searchBar: theSearchBar, contentsController: self)
-            searchController.delegate = self
-            searchController.searchResultsDataSource = self
-            searchController.searchResultsDelegate = self
-            theSearchBar.becomeFirstResponder()
+            searchController = UISearchController(searchResultsController: nil)
+            searchController.searchResultsUpdater = self
+            searchController.dimsBackgroundDuringPresentation = false
+            tableView.tableHeaderView = searchController.searchBar
         }
     }
     


// MARK: - UISearchDisplayDelegate

extension MICountryPicker: UISearchDisplayDelegate {
    
    func searchDisplayController(controller: UISearchDisplayController, shouldReloadTableForSearchScope searchOption: Int) -> Bool {
        
        filter(searchDisplayController!.searchBar.text!)
        return true
    }
    
    func searchDisplayController(controller: UISearchDisplayController, shouldReloadTableForSearchString searchString: String?) -> Bool {
        filter(searchString!)
        return true
    }
}

extension MICountryPicker {
    
    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        if searchController.searchBar.isFirstResponder() {
            return 1
        }
        return sections.count
    }
    
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if searchController.searchBar.isFirstResponder() {
            return filteredList.count
        }
        return sections[section].countries.count
    }
