UISearchController, uisearchbar

Source: Internet
Author: User

UISearchController, uisearchbar

Use of UISearchController in the search box (replacing UISearchBar + UIS after iOS8.0)

1. In iOS 8.0 and later versions, we can use UISearchController to conveniently Add the search box to UITableView. in earlier versions, we still have to use the combination of UISearchBar and UISearchDisplayController.

2. Before using UISearchController, define the following attributes:

 

// Define a UISearchController @ property (nonatomic, strong) UISearchController * searchController; // It is used to display the search result @ property (nonatomic, strong) ResultViewController * resultVC; // receives the searchController search result @ property (nonatomic, strong) NSMutableArray * searchArr;

// Open up a space to accept the search result _ searchArr = [[NSMutableArray alloc] init]; // instantiate searchController _ searchController = [[UISearchController alloc] initWithSearchResultsController: _ resultVC]; // set the proxy _ searchController called when searching for updates. searchResultsUpdater = self; // set the search box, adaptive, otherwise the search box cannot display [_ searchController. searchBar sizeToFit]; // Add the search box to tableView [_ tableView addSubview: _ searchController. searchBar]; // the following attributes indicate that the settings are not set. // set whether the background is displayed when the search starts. _ searchController. dimsBackgroundDuringPresentation = NO; // when searching, the background is dimmed _ searchController. dimsBackgroundDuringPresentation = NO; // when searching, the background changes to fuzzy _ searchController. obscuresBackgroundDuringPresentation = NO; // hide the navigation bar _ searchController. hidesNavigationBarDuringPresentation = NO;

  

Related Article

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.