public override void ViewDidLoad () { base.ViewDidLoad (); resultsTableController = new ResultsTableController { FilteredProducts = new List<Product> () }; searchController = new UISearchController (resultsTableController) { WeakDelegate = this, DimsBackgroundDuringPresentation = false, WeakSearchResultsUpdater = this }; searchController.SearchBar.SizeToFit (); TableView.TableHeaderView = searchController.SearchBar; resultsTableController.TableView.WeakDelegate = this; searchController.SearchBar.WeakDelegate = this; DefinesPresentationContext = true; if (searchControllerWasActive) { searchController.Active = searchControllerWasActive; searchControllerWasActive = false; if (searchControllerSearchFieldWasFirstResponder) { searchController.SearchBar.BecomeFirstResponder (); searchControllerSearchFieldWasFirstResponder = false; } } }
public override void ViewDidLoad() { base.ViewDidLoad(); resultsTableController = new ResultsTableController { FilteredProducts = new List <Product> () }; searchController = new UISearchController(resultsTableController) { WeakDelegate = this, DimsBackgroundDuringPresentation = false, WeakSearchResultsUpdater = this }; searchController.SearchBar.SizeToFit(); TableView.TableHeaderView = searchController.SearchBar; resultsTableController.TableView.WeakDelegate = this; searchController.SearchBar.WeakDelegate = this; DefinesPresentationContext = true; if (searchControllerWasActive) { searchController.Active = searchControllerWasActive; searchControllerWasActive = false; if (searchControllerSearchFieldWasFirstResponder) { searchController.SearchBar.BecomeFirstResponder(); searchControllerSearchFieldWasFirstResponder = false; } } }
public override void ViewDidLoad() { base.ViewDidLoad(); this.resultsTableController = new ResultsTableController(); this.resultsTableController.TableView.Delegate = this; this.searchController = new UISearchController(this.resultsTableController) { SearchResultsUpdater = this }; this.searchController.SearchBar.AutocapitalizationType = UITextAutocapitalizationType.None; if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { // For iOS 11 and later, place the search bar in the navigation bar. base.NavigationItem.SearchController = this.searchController; // Make the search bar always visible. base.NavigationItem.HidesSearchBarWhenScrolling = false; } else { // For iOS 10 and earlier, place the search controller's search bar in the table view's header. base.TableView.TableHeaderView = this.searchController.SearchBar; } this.searchController.Delegate = this; this.searchController.DimsBackgroundDuringPresentation = false; // The default is true. this.searchController.SearchBar.Delegate = this; // Monitor when the search button is tapped. /* * Search presents a view controller by applying normal view controller presentation semantics. * This means that the presentation moves up the view controller hierarchy until it finds the root * view controller or one that defines a presentation context. */ /* * Specify that this view controller determines how the search controller is presented. * The search controller should be presented modally and match the physical size of this view controller. */ this.DefinesPresentationContext = true; }