本文整理汇总了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);
}
示例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 ();
}
示例3: CancelButtonClicked
public override void CancelButtonClicked (UISearchBar searchBar)
{
searchBar.ShowsCancelButton = false;
searchBar.ResignFirstResponder ();
searchBar.Text = string.Empty;
_searchTextChanging.OnNext(searchBar.Text);
}
示例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);
}
}
示例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 ();
};
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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 ();
}
示例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;
}
示例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 ();
}
示例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);
}
示例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 ();
}
示例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 ();
}