<span id="Label3"></p><span id="OSC_h2_1"><span id="OSC_h2_1"></span></span>Uisearchbar (search box) Usage Summary in iOS<p><p><span style="font-size: 16px;">Initialize: Uisearchbar inherits from uiview, we can create a searchbar like a view</span><br></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">Uisearchbar * bar = [[uisearchbar alloc]initwithframe:cgrectmake (20, 100, 250, 40)]; [self.view addsubview:bar];</pre></pre> <p><p><span style="font-size: 16px;">@property (nonatomic) Uibarstyle barstyle;</span></p></p> <p><p><span style="font-size: 16px;">This property can be set to the style of the Searchbar search box, enumerated as Follows:</span></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">typedef ns_enum (nsinteger, Uibarstyle) {uibarstyledefault = 0,//default style white search box, multi-out background is gray Uibarstyleblack = 1,//black style, Black search box//the following two enumerations have been disabled, acting like black style Uibarstyleblackopaque = 1,//Deprecated. Use Uibarstyleblack uibarstyleblacktranslucent = 2,//Deprecated. Use Uibarstyleblack and set the translucent property to YES};</pre></pre> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,copy) NSString *text;</span></p></p> <p><p><span style="font-size: 16px;">Set the text in the search box</span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,copy) NSString *prompt;</span></p></p> <p><p><span style="font-size: 16px;">The official explanation of this property is to display a line of text at the top of the search box, which is actually the background text, stating:</span></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">Bar.prompt = @ "search box"; [email protected] "321111111111111111111111111"</pre></pre> <p><p><span style="font-size: 16px;">The effect is as Follows:</span><br></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,copy) NSString *placeholder;</span></p></p> <p><p><span style="font-size: 16px;">Same as placeholder of other text input controls, disappears when text is entered</span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) BOOL showsbookmarkbutton;</span></p></p> <p><p><span style="font-size: 16px;">Whether to display a Book's button to the right of the search box, the default is no,yes as Follows:</span><br></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) BOOL showscancelbutton;</span></p></p> <p><p><span style="font-size: 16px;">If the Cancel button is displayed, the default is no,yes as Follows:</span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) BOOL showssearchresultsbutton;</span></p></p> <p><p><span style="font-size: 16px;">If the search results button is displayed, the default No,yes effect is as Follows:</span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic, getter=issearchresultsbuttonselected) BOOL searchresultsbuttonselected;</span></p></p> <p><p><span style="font-size: 16px;">Set the search Results button to the selected state</span></p></p> <p><p><span style="font-size: 16px;">-(void) setshowscancelbutton: (bool) Showscancelbutton animated: (bool) animated;</span></p></p> <p><p><span style="font-size: 16px;">Set Display Cancel button</span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,retain) Uicolor *tintcolor;</span></p></p> <p><p><span style="font-size: 16px;">Setting this color value affects the color of the cursor in the search box</span><br></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,retain) Uicolor *bartintcolor;</span></p></p> <p><p><span style="font-size: 16px;">Setting this color affects the background color of the search box</span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) Uisearchbarstyle searchbarstyle;</span></p></p> <p><p><span style="font-size: 16px;">To set the overall style of the search box, enumerate the following:</span></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">typedef ns_enum (nsuinteger, Uisearchbarstyle) {uisearchbarstyledefault,//currently uisearchbarstyleprominent U Isearchbarstyleprominent,//display background uisearchbarstyleminimal//do not display background} Ns_enum_available_ios (7_0);</pre></pre> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,assign,getter=istranslucent) BOOL translucent;</span></p></p> <p><p><span style="font-size: 16px;">Set whether translucent</span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) BOOL showsscopebar;</span></p></p> <p><p><span style="font-size: 16px;">Whether to display the attachment selection button in the search bar trying to show this attempt, first set this property to yes, and then add a button to the button array, using this property:</span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,copy) Nsarray *scopebuttontitles;</span></p></p> <p><p><span style="font-size: 16px;">Set the selection button to try the button title</span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) Nsinteger selectedscopebuttonindex;</span></p></p> <p><p><span style="font-size: 16px;">Set a default Check button</span></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">Bar = [[uisearchbar Alloc]initwithframe:cgrectmake (20, 100, 250, 200)]; bar.showsscopebar=yes; Bar.scopebuttontitles = @[@ "12", @ "2", @ "3", @ "4"];</pre></pre> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic, readwrite, retain) UIView *inputaccessoryview;</span></p></p> <p><p><span style="font-size: 16px;">Attached to the keyboard</span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,retain) UIImage *backgroundimage;</span></p></p> <p><p><span style="font-size: 16px;">Set the background pattern for the search box</span><br></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic,retain) UIImage *scopebarbackgroundimage;</span></p></p> <p><p><span style="font-size: 16px;">Sets the background pattern of the secondary selection button view<br></span></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><span style="font-size: 16px;">-(void) setbackgroundimage: (UIImage *) backgroundimage forbarposition: (uibarposition) barposition barmetrics: ( Uibarmetrics) barmetrics;</span></p></p> <p><p><span style="font-size: 16px;">-(UIImage *) backgroundimageforbarposition: (uibarposition) barposition barmetrics: (uibarmetrics) barMetrics</span></p></p> <p><p><span style="font-size: 16px;">This pair of methods can set and get the background pattern of the search box under a State enumeration</span></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">-(void) setsearchfieldbackgroundimage: (UIImage *) backgroundimage forstate: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">-(UIImage *) searchfieldbackgroundimageforstate: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">This pair of methods is used to set and get the background pattern of TextField in the search box</span></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><span style="font-size: 16px;">-(void) setimage: (UIImage *) iconimage forsearchbaricon: (uisearchbaricon) icon state: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">-(UIImage *) imageforsearchbaricon: (uisearchbaricon) icon state: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">This pair of methods is used to get and set the pattern of the search bar icon picture</span></p></p> <p><p><span style="font-size: 16px;">-(void) setscopebarbuttonbackgroundimage: (UIImage *) backgroundimage forstate: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">-(UIImage *) scopebarbuttonbackgroundimageforstate: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">This pair of methods is used to set and get the background pattern of the search Box's additional selection button view</span></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">-(void) setscopebarbuttondividerimage: (UIImage *) dividerimage forleftsegmentstate: (uicontrolstate) leftstate Rightsegmentstate: (uicontrolstate) rightstate;</span></p></p> <p><p><span style="font-size: 16px;">-(UIImage *) scopebarbuttondividerimageforleftsegmentstate: (uicontrolstate) leftstate rightsegmentstate: ( Uicontrolstate) rightstate;</span></p></p> <p><p><span style="font-size: 16px;">This pair of methods is used to get and set the pattern of the toggle button in the Additional selection button view</span></p></p> <p><p><br></p></p> <p><p><span style="font-size: 16px;">-(void) setscopebarbuttontitletextattributes: (nsdictionary *) attributes forstate: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">-(nsdictionary *) scopebarbuttontitletextattributesforstate: (uicontrolstate) state;</span></p></p> <p><p><span style="font-size: 16px;">This pair of methods is used to set and get the Font property dictionary for toggle button Caption text</span></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) Uioffset searchfieldbackgroundpositionadjustment;</span></p></p> <p><p><span style="font-size: 16px;">The position offset of the search text in the search box</span></p></p> <p><p><span style="font-size: 16px;">@property (nonatomic) Uioffset searchtextpositionadjustment;</span></p></p> <p><p><span style="font-size: 16px;"></span><span style="font-size: 16px; line-height: 22.5px;">TextField position offset in the search box</span></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><span style="font-size: 16px;">-(void) setpositionadjustment: (uioffset) adjustment forsearchbaricon: (uisearchbaricon) icon;</span></p></p> <p><p><span style="font-size: 16px;">-(uioffset) positionadjustmentforsearchbaricon: (uisearchbaricon) icon;</span></p></p> <p><p><span style="font-size: 16px;">To set the position offset of the picture in the search bar, the image is enumerated as Follows:</span></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">typedef ns_enum (nsinteger, Uisearchbaricon) {uisearchbariconsearch,//search icon uisearchbariconclear,//clear icon Uisearc Hbariconbookmark,//book icon Uisearchbariconresultslist,//result List icon};</pre></pre> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;">Here are some proxy methods for the search box control:</span></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">-(BOOL) searchbarshouldbeginediting: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">The callback that will start editing, returned as no, cannot be edited</span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbartextdidbeginediting: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">Callbacks that have started editing</span></p></p> <p><p><span style="font-size: 16px;">-(BOOL) searchbarshouldendediting: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">Callback to end Edit</span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbartextdidendediting: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">Callback that has finished editing</span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbar: (uisearchbar *) searchbar textdidchange: (nsstring *) searchtext; Edit the callback for the text change</span></p></p> <p><p><span style="font-size: 16px;">-(BOOL) searchbar: (uisearchbar *) searchbar shouldchangetextinrange: (nsrange) range replacementtext: (nsstring *) text;</span></p></p> <p><p><span style="font-size: 16px;">Edit the callback before the text changes, return No to add new editing text</span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbarsearchbuttonclicked: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">Callback for Search button click</span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbarbookmarkbuttonclicked: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">The callback of the book button click</span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbarcancelbuttonclicked: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">Cancel button click of callback</span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbarresultslistbuttonclicked: (uisearchbar *) searchbar;</span></p></p> <p><p><span style="font-size: 16px;">Callback for the Search results button click</span></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><span style="font-size: 16px;">-(void) searchbar: (uisearchbar *) searchbar selectedscopebuttonindexdidchange: (nsinteger) selectedscope;</span></p></p> <p><p><span style="font-size: 16px;">The callback that is triggered by the toggle button in the additional attempt in the search bar</span></p></p> <p><p><span style="font-size: 16px;"><br></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"></span><br></p></p> <p><p><span style="font-size: 16px;"><br></span><br></p></p> <p><p><br></p></p> <p><p><span style="font-size: 16px;"><br></span></p></p> <p><p><br></p></p><p><p>Uisearchbar (search box) Usage Summary in iOS</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service