当前位置: 首页>>代码示例>>C#>>正文


C# UISearchBar类代码示例

本文整理汇总了C#中UISearchBar的典型用法代码示例。如果您正苦于以下问题:C# UISearchBar类的具体用法?C# UISearchBar怎么用?C# UISearchBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UISearchBar类属于命名空间,在下文中一共展示了UISearchBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            FoundCoords += (object sender, CoordEventArgs e) => {
                storageScreenContent.SetCoords(e.Latitude,e.Longitude);
            };

            map = new MKMapView (UIScreen.MainScreen.Bounds);
            View = map;

            // create search controller
            searchBar = new UISearchBar (new RectangleF (0, 0, View.Frame.Width, 50)) {
                Placeholder = "Enter a search query"
            };
            searchController = new UISearchDisplayController (searchBar, this);
            searchController.Delegate = new SearchDelegate (map);
            SearchSource source = new SearchSource (searchController, map);
            searchController.SearchResultsSource = source;
            source.FoundCoords += (object sender, CoordEventArgs e) => {
                var handler = FoundCoords;
                if(handler != null){
                    handler(this,e);
                }
                this.DismissViewController(true,null);
            };
            View.AddSubview (searchBar);
        }
开发者ID:KuroiAme,项目名称:Indexer,代码行数:28,代码来源:AddressLocationFinder.cs

示例2: ViewWillAppear

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);

            TableView.Source = new SearchTableSource(this);
            mSearchBar = TableView.TableHeaderView as UISearchBar;

            mSearchBar.Placeholder = "Enter Search Word";
            mSearchBar.SizeToFit();
            mSearchBar.AutocorrectionType = UITextAutocorrectionType.Yes;
            mSearchBar.AutocapitalizationType = UITextAutocapitalizationType.None;
            mSearchBar.SearchButtonClicked += (sender, e) =>
            {
                AddWord(mSearchBar.Text);
            };
            mSearchBar.TextChanged += (sender, e) =>
            {
                mSuggestionModel.NewSuggestion(mSearchBar.Text);
            };

            mSuggestionModel.SuggestionChanged += (sender, e) =>
            {
                this.InvokeOnMainThread(delegate
                {
                    TableView.ReloadData();
                });
            };

            mSearchBar.BecomeFirstResponder ();
        }
开发者ID:vmendi,项目名称:ListenAndRepeat,代码行数:30,代码来源:AddWordController.cs

示例3: CancelButtonClicked

 public override void CancelButtonClicked (UISearchBar searchBar)
 {
     searchBar.ShowsCancelButton = false;
     searchBar.ResignFirstResponder ();
     searchBar.Text = string.Empty;
     _searchTextChanging.OnNext(searchBar.Text);
 }
开发者ID:runt18,项目名称:CodeHub,代码行数:7,代码来源:ObservableSearchDelegate.cs

示例4: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            TableView.AllowsSelection = true;
            TableView.SetCellStyle(UITableViewCellStyle.Subtitle);
            using (var set = new BindingSet<UITableView, TableViewModel>(TableView))
            {
                var editItem = new UIBarButtonItem { Title = "Edit" };
                editItem.Clicked += (sender, args) =>
                {
                    TableView.Editing = !TableView.Editing;
                    NavigationItem.RightBarButtonItem.Title = TableView.Editing ? "Done" : "Edit";
                };
                var addItem = new UIBarButtonItem { Title = "Add" };
                set.Bind(addItem).To(() => (vm, ctx) => vm.AddCommand);
                NavigationItem.RightBarButtonItems = new[] { editItem, addItem };

                var searchBar = new UISearchBar(new RectangleF(0, 0, 320, 44)) { Placeholder = "Filter..." };
                set.Bind(searchBar).To(() => (vm, ctx) => vm.FilterText).TwoWay();
                TableView.TableHeaderView = searchBar;

                set.Bind(AttachedMemberConstants.ItemsSource)
                    .To(() => (vm, ctx) => vm.GridViewModel.ItemsSource);
                set.Bind(AttachedMemberConstants.SelectedItem)
                    .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem)
                    .TwoWay();
                set.Bind(this, () => controller => controller.Title)
                    .To(() => (vm, ctx) => vm.GridViewModel.SelectedItem.Name)
                    .WithFallback("Nothing selected");
                TableView.SetBindingMemberValue(AttachedMembers.UITableView.ItemTemplateSelector, TableCellTemplateSelector.Instance);
            }
        }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit.Samples,代码行数:34,代码来源:TableTemplateViewController.cs

示例5: CustomSearchController

		public CustomSearchController (ViewController owner, UISearchBar searchBar, UITableView searchPredictionTable, List<Room> rooms)
		{
			_searchBar = searchBar;
			_searchPredictionTable = searchPredictionTable;
			owner.InvokeOnMainThread (delegate() {
				_searchPredictionTable.Alpha = 0;
			});

			tableSource = new TableSource (owner, rooms);
			_searchPredictionTable.Source = tableSource;

			_searchBar.TextChanged += (sender, e) => {
				owner.InvokeOnMainThread (delegate() {
                    tableSource.tableItems = rooms.FindAll ((room) => room.Name.ToLower().Contains (e.SearchText.ToLower())).ToArray ();
					_searchPredictionTable.ReloadData();
				});
			};

			_searchBar.CancelButtonClicked += (sender, e) => {
				_searchBar.ShowsCancelButton = false;
				_searchBar.ResignFirstResponder();
			};

			_searchBar.OnEditingStarted += (sender, e) => {
				_searchBar.ShowsCancelButton = true;
				_searchPredictionTable.Alpha = 1;
			};
            _searchBar.OnEditingStopped += (sender, e) => {
                _searchPredictionTable.Alpha = 0;
                _searchBar.ResignFirstResponder ();

            };

		}
开发者ID:dcbright01,项目名称:Navigator,代码行数:34,代码来源:CustomSearchController.cs

示例6: LoadView

        public override void LoadView()
        {
            base.LoadView();
            this.IsSearching = false;

            PillboxClient.Initialize();
            _Service = new DBManagerService(@"http://mor.nlm.nih.gov/axis/services/RxNormDBService");

            _SearchBar = new UISearchBar();
            _SearchBar.Text = "sildenafil";
            _SearchBar.Frame = new RectangleF(0, -44, View.Frame.Width, 44);
            _SearchBar.SearchButtonClicked += delegate {
                Search(_SearchBar.Text);
            };
            _SearchBar.CancelButtonClicked += delegate {
                SearchCancelled();
            };

            _SearchingView = new DrugSearchingView(SearchCancelled);
            _SearchingView.Hidden = true;

            this.TableView.ContentInset = new UIEdgeInsets(44, 0, 0, 0);

            this.View.AddSubview(_SearchingView);
            this.View.AddSubview(_SearchBar);
        }
开发者ID:ZAD-Man,项目名称:Zadify,代码行数:26,代码来源:DrugSearchViewController.cs

示例7: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            this.NavigationItem.Title = "Phrases";
            this.NavigationController.NavigationBar.BarStyle = UIBarStyle.BlackOpaque;
            this.NavigationController.NavigationBar.TintColor = UIColor.White;
            this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGB (0, 176, 202);
            this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes()
            {
                ForegroundColor = UIColor.White
            };

            // add table view
            var width = View.Bounds.Width;
            var height = View.Bounds.Height;

            table = new UITableView (new CGRect (0, 0, width, height));
            table.AutoresizingMask = UIViewAutoresizing.All;
            table.RowHeight = UITableView.AutomaticDimension;

            //remove seperator lines if cell are empty;
            var frame = new CGRect (0, 0, 0, 0);
            table.TableFooterView = new UIView (frame);

            //add search bar
            UISearchBar searchBar = new UISearchBar ();
            searchBar.SizeToFit ();
            table.TableHeaderView = searchBar;

            DisplayCategories (searchBar);
            Add (table);
        }
开发者ID:Jusliang,项目名称:Ma-Phrase-Book,代码行数:32,代码来源:CategoryScreen.cs

示例8: FlyoutNavigationController

        public FlyoutNavigationController(UITableViewStyle navigationStyle = UITableViewStyle.Plain)
        {
            navigation = new DialogViewController(navigationStyle,null);
            navigation.OnSelection += NavigationItemSelected;
            var navFrame = navigation.View.Frame;
            navFrame.Width = menuWidth;
            navigation.View.Frame = navFrame;
            this.View.AddSubview (navigation.View);
            SearchBar = new UISearchBar (new RectangleF (0, 0, navigation.TableView.Bounds.Width, 44)) {
                //Delegate = new SearchDelegate (this),
                TintColor = this.TintColor
            };

            TintColor = UIColor.Black;
            //navigation.TableView.TableHeaderView = SearchBar;
            navigation.TableView.TableFooterView = new UIView (new RectangleF (0, 0, 100, 100)){BackgroundColor = UIColor.Clear};
            navigation.TableView.ScrollsToTop = false;
            shadowView = new UIView ();
            shadowView.BackgroundColor = UIColor.White;
            shadowView.Layer.ShadowOffset = new System.Drawing.SizeF (-5, -1);
            shadowView.Layer.ShadowColor = UIColor.Black.CGColor;
            shadowView.Layer.ShadowOpacity = .75f;
            closeButton = new UIButton ();
            closeButton.TouchDown += delegate {
                HideMenu ();
            };
            AlwaysShowLandscapeMenu = true;

            this.View.AddGestureRecognizer (new OpenMenuGestureRecognizer (this, new Selector ("panned"), this));

            ShouldAutoPushFirstView = true;
        }
开发者ID:neilkennedy,项目名称:FlyoutNavigation,代码行数:32,代码来源:FlyoutNavigationController.cs

示例9: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var source = new MvxStandardTableViewSource(TableView, "TitleText FullName;ImageUrl Picture");
            TableView.Source = source;

            _searchBar = new UISearchBar();
            _searchBar.Placeholder = "Enter Search Text";
            _searchBar.SetShowsCancelButton(true, true);
            _searchBar.SizeToFit();
            _searchBar.AutocorrectionType = UITextAutocorrectionType.No;
            _searchBar.AutocapitalizationType = UITextAutocapitalizationType.None;
            _searchBar.CancelButtonClicked += SearchBarCancelButtonClicked;
            _searchBar.SearchButtonClicked += (sender, e) => { PerformSearch(); };

            MvxFluentBindingDescriptionSet<FriendsViewController, FriendsViewModel> set =
                this.CreateBindingSet<FriendsViewController, FriendsViewModel>();
            set.Bind(source).To(x => x.Friends);
            set.Bind(source).For(s => s.SelectionChangedCommand).To(vm => vm.ViewDetailsCommand);

            set.Bind(_searchBar).For(x => x.Text).To(vm => vm.SearchTerm);
            set.Apply();

            TableView.ReloadData();

            TableView.TableHeaderView = _searchBar;
        }
开发者ID:slown1,项目名称:Xamarin.Chat,代码行数:28,代码来源:FriendsViewController.cs

示例10: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            this.Title = title;

            var frame = new CGRect (0, 0, 0, 0);
            TableView.TableFooterView = new UIView (frame);
            TableView.AutoresizingMask = UIViewAutoresizing.All;
            TableView.RowHeight = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 200f;

            UISearchBar searchBar = new UISearchBar ();
            searchBar.SizeToFit ();
            TableView.TableHeaderView = searchBar;

            UISearchDisplayController searchDisplayController = new UISearchDisplayController(searchBar, this);

            var phraseSource = new PhraseSource (this);
            TableView.Source = phraseSource;

            searchDisplayController.SearchResultsSource = phraseSource;
            searchDisplayController.SearchBar.TextChanged += (sender, e) => {
                string text = e.SearchText.Trim ();
                filteredPhrases = (from phrase in phrases
                    where phrase.sourcePhrase.ToUpper ().Contains (text.ToUpper ())
                   	select phrase).ToList ();
            };
            searchDisplayController.SearchResultsTableView.RowHeight = UITableView.AutomaticDimension;
            searchDisplayController.SearchResultsTableView.EstimatedRowHeight = 200f;

            LoadDataForDisplay ();
        }
开发者ID:Jusliang,项目名称:Ma-Phrase-Book,代码行数:32,代码来源:PhraseScreen.cs

示例11: LoadView

        public override void LoadView()
        {
            base.LoadView();

            InfosTableView = new UITableView(RectangleF.Empty, UITableViewStyle.Plain)
            {
                Frame = this.ContentFrame(),
                Source = new InfosTableSource(),
                RowHeight = 60
            };
            View.AddSubview(InfosTableView);

            var searchBar = new UISearchBar(RectangleF.Empty)
            {
                ShowsCancelButton = true,
                Placeholder = "Find Currency",
                KeyboardType = UIKeyboardType.ASCIICapable
            };
            searchBar.SizeToFit();
            InfosTableView.TableHeaderView = searchBar;

            SearchController = new UISearchDisplayController(searchBar, this)
            {
                Delegate = new SearchDisplayDelegate(),
                SearchResultsSource = new InfosTableSource()
            };
            SearchController.SearchResultsTableView.RowHeight = 60;
        }
开发者ID:seanho,项目名称:CurrencyApp-MonoTouch,代码行数:28,代码来源:CurrenciesController.cs

示例12: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			if (cloudManager != null)
				cloudManager.FetchRecords ("SearchRequest", results => {
					previousSearchRequests = results;
					TableView.ReloadData ();
				});

			NavigationItem.HidesBackButton = true;
			TableView.Source = new TableSource (this);
			TableView.AllowsMultipleSelectionDuringEditing = false;

			searchBar = new UISearchBar {
				Placeholder = "search_hint".LocalizedString ("Search text field placeholder"),
				AutocorrectionType = UITextAutocorrectionType.No,
				AutocapitalizationType = UITextAutocapitalizationType.None,
				ShowsCancelButton = true
			};

			searchBar.SizeToFit ();
			searchBar.SearchButtonClicked += (sender, e) => {
				if (cloudManager != null && 
					!previousSearchRequests.Where (record => (NSString)record ["value"] == searchBar.Text).Any ())
					SaveSearchRequest (searchBar.Text);
				
				Search ();
			};

			searchBar.CancelButtonClicked += (sender, e) => NavigationController.PopViewController (false);

			NavigationItem.TitleView = searchBar;
			searchBar.BecomeFirstResponder ();
		}
开发者ID:RobGibbens,项目名称:Coffee-Filter,代码行数:35,代码来源:SearchViewController.cs

示例13: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			NavBar=new UINavigationBar(new CoreGraphics.CGRect (0, 0, pview.uvWidth, 44));
			NavBar.BackgroundColor = UIColor.Red;
//			UIBarButtonItem bbitemCancel = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, CancelButtonClicked);
			UIButton btnCancel = new UIButton (new CGRect (0, 0, 80, 30));
			btnCancel.SetTitleColor (UIColor.Blue, UIControlState.Normal);
			btnCancel.SetTitle ("Cancel", UIControlState.Normal);
			btnCancel.TouchUpInside += (object sender, EventArgs e) => {
				pview.popover.Dismiss(false);
			};
			UIBarButtonItem bbitemCancel = new UIBarButtonItem (btnCancel);

//			UIBarButtonItem bbitemDone = new UIBarButtonItem (UIBarButtonSystemItem.Done, DoneButtonClicked);
			UIButton btnDone = new UIButton (new CGRect (0, 0, 80, 30));
			btnDone.SetTitleColor (UIColor.Blue, UIControlState.Normal);
			btnDone.SetTitle ("Done", UIControlState.Normal);
			btnDone.TouchUpInside += (object sender, EventArgs e) => {
				pview.DismissPopOver ();
			};
			UIBarButtonItem bbitemDone = new UIBarButtonItem (btnDone);

			UINavigationItem navgitem = new UINavigationItem ("Select");
			navgitem.SetLeftBarButtonItem(bbitemCancel,true);
			navgitem.SetRightBarButtonItem (bbitemDone, true);
			NavBar.PushNavigationItem(navgitem,true);
			this.View.Add (NavBar);
			searchBar=new UISearchBar(new CoreGraphics.CGRect (0, 44, pview.uvWidth, 44));
			this.View.Add(searchBar);
			rvc = new RootViewController (RootData,pview);
			rvc.View.Frame = new CoreGraphics.CGRect (0, 88, pview.uvWidth, 600);
			this.subview.SetRootview(rvc);
			this.View.Add (rvc.View);
		}
开发者ID:Nahidahmed,项目名称:iProPQRS,代码行数:35,代码来源:RootGroupView.cs

示例14: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            this.Title = "My Phrases";

            //create a table
            var width = View.Bounds.Width;
            var height = View.Bounds.Height;
            table = new UITableView (new CGRect (0, 0, width, height));
            table.AutoresizingMask = UIViewAutoresizing.All;
            table.RowHeight = UITableView.AutomaticDimension;
            table.EstimatedRowHeight = 44f;

            //remove seperator lines if cell are empty;
            var frame = new CGRect (0, 0, 0, 0);
            table.TableFooterView = new UIView (frame);

            //add search bar
            UISearchBar searchBar = new UISearchBar ();
            searchBar.SizeToFit ();
            table.TableHeaderView = searchBar;

            DisplayMyPhrases (myPhraseCategoryId, searchBar);
            Add (table);
            DisplayAddMyPhrases ();
        }
开发者ID:Jusliang,项目名称:Ma-Phrase-Book,代码行数:26,代码来源:MyPhraseScreen.cs

示例15: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            LoadWords ();

            Background back = new Background();
            View.Add(back.View);
            View.SendSubviewToBack (back.View);

            RectangleF resultsRect = new RectangleF (0, 75, View.Bounds.Width, View.Bounds.Height - 75);
            resultsTable = new UITableView (resultsRect);
            resultsTable.BackgroundColor = UIColor.Clear;
            Add (resultsTable);
            searchBar = new UISearchBar (new RectangleF(0, 0, View.Bounds.Width, 40));
            searchBar.Text = this.initialSearch;
            Add (searchBar);

            tableSource = new WordsTableSource(this);
            resultsTable.Source = tableSource;

            searchBar.SearchButtonClicked += (s, e) => searchBar.ResignFirstResponder ();

            // refine the search results every time the text changes
            searchBar.TextChanged += (s, e) => RefineSearchItems ();

            RefineSearchItems ();
        }
开发者ID:KuroiAme,项目名称:Indexer,代码行数:28,代码来源:SearchScreen.cs


注:本文中的UISearchBar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。