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;

The use of Uisearchdisplaycontroller requires:

    • Provides the source of data for the search results table-searchresultsdatasource
    • Agent searchresultsdelegate for search results table
    • The proxy delegate of the Uisearchdisplaycontroller controller, which corresponds to the beginning and end of the search event and the display of the Hidden interface; (This agent knows the change and search scope of the search string.) So the result table can (self-actively) import again)
    • Searchbar's agent (about Uisearchbar Agent previous article has been explained)

It is common to initialize Uisearchdisplaycontroller 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 infer 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 (hide) state, default value is no, direct set no animation. With setActive:animated: settings There will be animations

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

Agent

@property (nonatomic, assign) BOOL Displayssearchbarinnavigationbar

Specify Navigationbar to include 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 > Searchresultsdatasource

Show data sources for search results

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

proxy for table displayed by search results

@property (Nonatomic, readonly)   uitableview

search results show Table

@property (nonatomic, copy)   nsstring *searchresultstitle

title of search results View

-(ID) Initwithsearchbar: ( uisearchbar *) searchbar  contentscontroller: ( uiviewcontroller *) viewcontroller

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

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.