/// <summary>
		/// Views the did load.
		/// </summary>
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// Register the tableview's datasource
			TableView.Source = new MainMenuTableSource (this);

			// Create a search results table
			var searchResultsController = new UITableViewController (UITableViewStyle.Plain);
			var searchSource = new SearchResultsTableSource (this);
			searchResultsController.TableView.Source = searchSource;

			// Create search updater and wire it up
			var searchUpdater = new SearchResultsUpdator ();
			searchUpdater.UpdateSearchResults += (searchText) => {
				// Preform search and reload search table
				searchSource.Search(searchText);
				searchResultsController.TableView.ReloadData();
			};

			// Create a new search controller
			SearchController = new UISearchController (searchResultsController);
			SearchController.SearchResultsUpdater = searchUpdater;

			// Display the search controller
			SearchController.SearchBar.Frame = new CGRect (SearchController.SearchBar.Frame.X, SearchController.SearchBar.Frame.Y, SearchController.SearchBar.Frame.Width, 44f);
			TableView.TableHeaderView = SearchController.SearchBar;
			DefinesPresentationContext = true;
		}
Beispiel #2
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Register the tableview's datasource
            TableView.Source = new MainMenuTableSource(this);

            // Create a search results table
            var searchResultsController = new UITableViewController(UITableViewStyle.Plain);
            var searchSource            = new SearchResultsTableSource(this);

            searchResultsController.TableView.Source = searchSource;

            // Create search updater and wire it up
            var searchUpdater = new SearchResultsUpdator();

            searchUpdater.UpdateSearchResults += (searchText) => {
                // Preform search and reload search table
                searchSource.Search(searchText);
                searchResultsController.TableView.ReloadData();
            };

            // Create a new search controller
            SearchController = new UISearchController(searchResultsController);
            SearchController.SearchResultsUpdater = searchUpdater;

            // Display the search controller
            SearchController.SearchBar.Frame = new CGRect(SearchController.SearchBar.Frame.X, SearchController.SearchBar.Frame.Y, SearchController.SearchBar.Frame.Width, 44f);
            TableView.TableHeaderView        = SearchController.SearchBar;
            DefinesPresentationContext       = true;
        }