iOS Guides | Samples

MonoTouch.UIKit.UISearchBar Class

A UIView that displays a search bar.

See Also: UISearchBar

Syntax

[MonoTouch.Foundation.Register("UISearchBar", true)]
public class UISearchBar : UIView, IUIBarPositioning, IUITextInputTraits, IDisposable

Remarks

The MonoTouch API supports two styles of event notification: the Objective-C style that uses a delegate class or the C# style using event notifications.

The C# style allows the user to add or remove event handlers at runtime by assigning to the events of properties of this class. Event handlers can be anyone of a method, an anonymous methods or a lambda expression. Using the C# style events or properties will override any manual settings to the Objective-C Delegate or WeakDelegate settings.

The Objective-C style requires the user to create a new class derived from UISearchBarDelegate class and assign it to the UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from NSObject which has every entry point properly decorated with an [Export] attribute. The instance of this object can then be assigned to the UISearchBar.WeakDelegate property.

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UISearchBar are listed below.

See Also: UIView

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
Initializes the UISearchBar with the specified frame.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
static
AppearanceUISearchBar+UISearchBarAppearance. Strongly-typed property that returns the UIAppearance class for this class.
AutocapitalizationTypeUITextAutocapitalizationType. The autocapitalization style used on the text.
AutocorrectionTypeUITextAutocorrectionType. The autocorrection style used on the text.
BackgroundImageUIImage. The UIImage shown in the background of the search bar.
[read-only]
BarPositionUIBarPosition. Gets the UIBarPosition of this UISearchBar view.
BarStyleUIBarStyle. The appearance of this UISearchBar.
BarTintColorUIColor. The tint applied to the background of this UISearchBar.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
DelegateUISearchBarDelegate. An instance of the MonoTouch.UIKit.UISearchBarDelegate model class which acts as the class delegate.
EnablesReturnKeyAutomaticallyBoolean. Gets or sets whether to enable the return key when a user enters text.
GetPositionForBarFunc<IUIBarPositioning, UIBarPosition>. Delegate invoked by the object to get a value.
InputAccessoryViewUIView. The custom input accessory for the keyboard of this UISearchBar.
[read-only]
InputAssistantItemUITextInputAssistantItem. Gets the assistant that will be used to configure the shortcut bar.
KeyboardAppearanceUIKeyboardAppearance. Gets or sets the appearance of the keyboard that is associated with this UISearchBar bar, as a UIKeyboardAppearance object.
KeyboardTypeUIKeyboardType. The keyboard style used for the text.
PlaceholderString. A string that is displayed when there is no other text in the text field.
PromptString. A line of text displayed at the top of this UISearchBar.
ReturnKeyTypeUIReturnKeyType. Gets or sets the UIReturnKeyType value for the return key that is associated with this UISearchBar bar.
ScopeBarBackgroundImageUIImage. The UIImage used for the background of the scope bar.
ScopeButtonTitlesString[]. The titles of the scope buttons.
SearchBarStyleUISearchBarStyle. The style used for this UISearchBar's appearance.
SearchFieldBackgroundPositionAdjustmentUIOffset. The offset of the search text field background in this UISearchBar.
SearchResultsButtonSelectedBoolean. Whether the search results button is selected.
SearchTextPositionAdjustmentUIOffset. The offset of the text in the search text field background.
SecureTextEntryBoolean. Gets or sets whether this UISearchBar bar hides the text that a user enters.
SelectedScopeButtonIndexInt32. The index of the selected scope button.
ShouldBeginEditingUISearchBarPredicate. Delegate invoked by the object to get a value.
ShouldChangeTextInRangeUISearchBarRangeEventArgs. Delegate invoked by the object to get a value.
ShouldEndEditingUISearchBarPredicate. Delegate invoked by the object to get a value.
ShowsBookmarkButtonBoolean. Whether the bookmark button is displayed.
ShowsCancelButtonBoolean. Whether the cancel button is displayed.
ShowsScopeBarBoolean. Whether the scope bar is displayed.
ShowsSearchResultsButtonBoolean. Whether the search results button is displayed.
SpellCheckingTypeUITextSpellCheckingType. The UITextSpellCheckingType used on this UISearchBar.
TextString. The current or starting search text.
TextContentTypeNSString. A hint of the type of data the field should contain (must be value from UITextContentType).
TranslucentBoolean. True if the search bar is translucent.
WeakDelegateNSObject. An object that can respond to the delegate protocol for this type

Public Methods

static
AppearanceWhenContainedIn(params Type[]) : UISearchBar+UISearchBarAppearance
Returns a strongly typed UIAppearance for instances of this class when the view is hosted in the specified hierarchy.
BackgroundImageForBarMetrics(UIBarMetrics) : UIImage
The background image used for the specified UIBarMetrics.
BackgroundImageForBarPosition(UIBarPosition, UIBarMetrics) : UIImage
The UIImage used for the background for the specified position and metrics.
static
GetAppearance(UITraitCollection) : UISearchBar+UISearchBarAppearance
Returns an appearance proxy for the specified traits.
static
GetAppearance(UITraitCollection, params Type[]) : UISearchBar+UISearchBarAppearance
Returns an appearance proxy for the specified traits when found in the containers containment hierarchy.
static
GetAppearance<T>() : UISearchBar+UISearchBarAppearance
Obtains the appearance proxy UISearchBarAppearance for the subclass of UISearchBar.
static
GetAppearance<T>(UITraitCollection) : UISearchBar+UISearchBarAppearance
Obtains the appearance proxy UISearchBarAppearance for the subclass of UISearchBar.
static
GetAppearance<T>(UITraitCollection, params Type[]) : UISearchBar+UISearchBarAppearance
Obtains the appearance proxy UISearchBarAppearance for the subclass of UISearchBar that has the specified trait collection when the view is hosted in the specified hierarchy.
GetImageForSearchBarIcon(UISearchBarIcon, UIControlState) : UIImage
The UIImage used for the specified search bar icon type and control state.
GetPositionAdjustmentForSearchBarIcon(UISearchBarIcon) : UIOffset
The position adjustment for the specified icon.
GetScopeBarButtonBackgroundImage(UIControlState) : UIImage
The UIImage used for the background for the specified scope bar button and state.
GetScopeBarButtonDividerImage(UIControlState, UIControlState) : UIImage
The UIImage used for the divider for the specified combination of left and right segment states.
GetScopeBarButtonTitleTextAttributes(UIControlState) : UITextAttributes
The text attributes of the scope bar button's title for the specified UIControlState.
GetSearchFieldBackgroundImage(UIControlState) : UIImage
The UIImage used for the background of the search text field for the specified state.
SetBackgroundImage(UIImage, UIBarMetrics)
The UIImage used in the background of the search bar.
SetBackgroundImage(UIImage, UIBarPosition, UIBarMetrics)
Sets the UIImage used for the background for the specified position and metrics.
SetImageforSearchBarIcon(UIImage, UISearchBarIcon, UIControlState)
Sets the icon for the specified search bar icon type and control state.
SetPositionAdjustmentforSearchBarIcon(UIOffset, UISearchBarIcon)
Sets the position adjustment for the specified icon.
SetScopeBarButtonBackgroundImage(UIImage, UIControlState)
Sets the UIImage used as the background image for the specified scope bar button and state.
SetScopeBarButtonDividerImage(UIImage, UIControlState, UIControlState)
Sets the UIImage used as the divider for the specified combination of left and right segment states.
SetScopeBarButtonTitle(UITextAttributes, UIControlState)
The title and attributes of the scope bar button for the specified UIControlState.
SetSearchFieldBackgroundImage(UIImage, UIControlState)
Sets the UIImage used as the background for the search text field for the specified state.
SetShowsCancelButton(Boolean, Boolean)
Sets the display state of the cancel button, optionally animating the change.

Protected Methods

override
Dispose(Boolean)
Releases the resources used by the UISearchBar object.

Public Events

BookmarkButtonClickedEvent raised by the object.
CancelButtonClickedEvent raised by the object.
ListButtonClickedEvent raised by the object.
OnEditingStartedEvent raised by the object.
OnEditingStoppedEvent raised by the object.
SearchButtonClickedEvent raised by the object.
SelectedScopeButtonIndexChangedEvent raised by the object.
TextChangedEvent raised by the object.