IOS Uisearchdisplaycontroller Learning Notes

Source: Internet
Author: User

UisearchdisplaycontrolleR and Uisearchbar are used together to manage the display of Uisearchbar and search results. Uisearchdisplaycontroller provides a tableview that displays search results to cover the original controller's view;

Using Uisearchdisplaycontroller requires:

    • Provides the source of data for the search results table-searchresultsdatasource
    • Agent searchresultsdelegate for search results table
    • Uisearchdisplaycontroller Controller Agent delegate, the corresponding search event start end and display hidden interface, (this agent knows the search string changes and search scope, so the result table can (auto) re-import)
    • Searchbar's agent (about Uisearchbar Agent previous article has been explained)

Usually the Uisearchdisplaycontroller is initialized in UITableView to show a list;

Searchcontroller = [[Uisearchdisplaycontroller alloc]                         initwithsearchbar:searchbar contentscontroller:self]; Searchcontroller.delegate = Self;searchcontroller.searchresultsdatasource = self; Searchcontroller.searchresultsdelegate = self;

In the Tabelview proxy method, you need to determine which table (Uitableviewcontroller has Self.tableview Uisearchdisplaycontroller. Searchresultstableview)

-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {     if (TableView = = Self.tableview) {        return ...;    }    If necessary (if the data source for other table views),    //Check whether TableView is Searchcontroller.sea Rchresultstableview.    return ...;}
A uiviewcontroller and a uisearchbar have only one uisearchdisplaycontroller;


You can use Searchdisplaycontroller in Navigationbar after iOS7, By configuring the Displayssearchbarinnavigationbar and Navigationitem attributes in the Uisearchdisplaycontroller;


Related properties and methods

@property (nonatomic, getter=isactive) BOOL active

Show (hidden) state, default value is no, direct set no animation, with setActive:animated: settings will be animated

@property (nonatomic, assign) id< Uisearchdisplaydelegate> Delegate

Agent

@property (nonatomic, assign) BOOL Displayssearchbarinnavigationbar

Specifies that Navigationbar contains a searchbar

@property (nonatomic, ReadOnly) Uinavigationitem *navigationitem

The read-only attribute represents the Searchdisplaycontroller in the Navigationbar of the navigation controller;

@property (nonatomic, ReadOnly) Uisearchbar *searchbar

Uisearchbar in the Uisearchdisplaycontroller;

@property (nonatomic, ReadOnly) Uiviewcontroller *searchcontentscontroller

This property manages what is searched for

@property (Nonatomic, assign) id< uitableviewdatasource

Show data sources for search results

@property (nonatomic, assign) id< uitableviewdelegate> searchresultsdelegate

proxy for table displayed by search results

@property (Nonatomic, readonly)   uitableview * Searchresultstableview

search results show Table

@property (nonatomic, copy)   nsstring *searchresultstitle

title of search results View

-(ID) InitWithSearchBar: ( uisearchbar *) searchbar   Contentscontroller: ( Uiviewcontroller  *) viewCo Ntroller

Initialize controller specifies associated search and view controller

-(void) SetActive: (BOOL) Visible animated: (BOOL) animated

Show or hide the search view

Content from Apple Docs


IOS Uisearchdisplaycontroller Learning Notes

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.