IOS UISearchBar learning notes

Source: Internet
Author: User

IOS UISearchBar learning notes

UISearchBar is a search control that provides a text input box, a search button, a bookmarks button, and a Cancel button. We need to use the UISearchBarDelegate proxy for search;

Drag a UISearchBar Control


Right sidebar attributes <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20141010/2014101008183216.jpg" alt = "\">

Text is the default text. The placeholder is the text displayed when the text is not edited. The prompt is the text displayed on the text box.


The preceding figure shows the corresponding text.

Continue attributes


These two attributes are used to set the style:



Used to set buttons;

The styles corresponding to the four buttons;






We can also set the background image:

They are


The above is used to set the background image, and the following is used to set the background image (when the fourth button scope bar is selected)




Next let's take a look at the Proxy: UIBarPositioningDelegate

Editing Text-searchBar: textDidChange: // when the search content changes, call-searchBar: shouldChangeTextInRange: replacementText: // This should replace the previous Text range with the last Text-searchBarShouldBeginEditing: // make the search box editable-searchBarTextDidBeginEditing: // call-searchBarShouldEndEditing: // when the user starts to edit the text-enable searchBarTextDidEndEditing: // call Clicking Buttons-searchBarBookmarkButtonClicked when the user finishes editing the text: // call-searchBarCancelButtonClicked when the user clicks the bookmark button: // call-searchBarSearchButtonClicked when the user clicks the cancel button: // call-searchBarResultsListButtonClicked when you click the search Button: // call Scope Button-searchBar: selectedScopeButtonIndexDidChange: // when the scope Button changes



You can take a look at common proxy Methods: Click to open the link




Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.