/// <summary>
		/// Shows the search controller.
		/// </summary>
		public void ShowSearchController ()
		{
			// Build an instance of the Search Results View Controller from the Storyboard
			ResultsController = Storyboard.InstantiateViewController (SearchResultsID) as SearchResultsViewController;
			if (ResultsController == null)
				throw new Exception ("Unable to instantiate a SearchResultsViewController.");

			// Create an initialize a new search controller
			var searchController = new UISearchController (ResultsController) {
				SearchResultsUpdater = ResultsController,
				HidesNavigationBarDuringPresentation = false
			};

			// Set any required search parameters
			searchController.SearchBar.Placeholder = "Enter keyword (e.g. coffee)";

			// The Search Results View Controller can be presented as a modal view
			// PresentViewController (searchController, true, null);

			// Or in the case of this sample, the Search View Controller is being
			// presented as the contents of the Search Tab directly. Use either one
			// or the other method to display the Search Controller (not both).
			var container = new UISearchContainerViewController (searchController);
			var navController = new UINavigationController (container);
			AddChildViewController (navController);
			View.Add (navController.View);
		}
Пример #2
0
        /// <summary>
        /// Shows the search controller.
        /// </summary>
        public void ShowSearchController()
        {
            // Build an instance of the Search Results View Controller from the Storyboard
            ResultsController = Storyboard.InstantiateViewController(SearchResultsID) as SearchResultsViewController;
            if (ResultsController == null)
            {
                throw new Exception("Unable to instantiate a SearchResultsViewController.");
            }

            // Create an initialize a new search controller
            var searchController = new UISearchController(ResultsController)
            {
                SearchResultsUpdater = ResultsController,
                HidesNavigationBarDuringPresentation = false
            };

            // Set any required search parameters
            searchController.SearchBar.Placeholder = "Enter keyword (e.g. coffee)";

            // The Search Results View Controller can be presented as a modal view
            // PresentViewController (searchController, true, null);

            // Or in the case of this sample, the Search View Controller is being
            // presented as the contents of the Search Tab directly. Use either one
            // or the other method to display the Search Controller (not both).
            var container     = new UISearchContainerViewController(searchController);
            var navController = new UINavigationController(container);

            AddChildViewController(navController);
            View.Add(navController.View);
        }