Last active
May 24, 2016 18:10
-
-
Save fongd/9501c346137d4ed9795c4dc6a8c465ef to your computer and use it in GitHub Desktop.
Revisions
-
fongd revised this gist
May 24, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ override func viewDidLoad() { let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("Search") @@ -12,7 +13,7 @@ let resultsController = SearchViewController() self.searchController.searchResultsUpdater = resultsController } ... -
fongd created this gist
May 24, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("Search") self.searchController = UISearchController(searchResultsController: vc) self.searchView.addSubview(searchController.searchBar) self.searchController.hidesNavigationBarDuringPresentation = false self.searchController.dimsBackgroundDuringPresentation = false self.searchController.searchBar.searchBarStyle = .Minimal self.searchController.searchBar.sizeToFit() self.navigationItem.titleView = searchController.searchBar self.definesPresentationContext = true let resultsController = SearchViewController() self.searchController.searchResultsUpdater = resultsController ... extension SearchViewController: UISearchResultsUpdating { func updateSearchResultsForSearchController(searchController: UISearchController) { let searchString = searchController.searchBar.text filteredArray = dataArray.filter({ (country) -> Bool in let countryText: NSString = country return (countryText.rangeOfString(searchString!, options: NSStringCompareOptions.CaseInsensitiveSearch).location) != NSNotFound }) tblSearchResults.reloadData() } }