IOS UISearchDisplayController learning notes, uisearchcontroller

Source: Internet
Author: User

IOS UISearchDisplayController learning notes, uisearchcontroller

UISearchDisplayControlleR and UISearchBar are used together to manage the display of UISearchBar and search results. UISearchDisplayController provides tableview for displaying search results to overwrite the view of the original controller;

To use UISearchDisplayController, you must:

  • SearchResultsDataSource
  • Search Result table proxy SearchResultsDelegate
  • The proxy delegate of the UISearchDisplayController. the start and end of the corresponding search event and the hidden interface are displayed. (This proxy knows the change of the search string and the search range, so the result table can be (automatically) re-imported)
  • SearchBar proxy (as described in the previous article about UISearchBar proxy)

UISearchDisplayController is initialized in uitableview to display 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 is used (UITableViewController has self. tableView UISearchDisplayController has. searchResultsTableView)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {     if (tableView == self.tableView) {        return ...;    }    // If necessary (if self is the data source for other table views),    // check whether tableView is searchController.searchResultsTableView.    return ...;}
One UIViewController and one UISearchBar have only one UISearchDisplayController;


After ios7, you can use SearchDisplayController in navigationbar and configure the displaysSearchBarInNavigationBar and navigationItem attributes in UISearchDisplayController;


Related attributes and Methods

@ Property (nonatomic, getter = isActive) BOOL active

Display (hide or not) status. The default value is NO. NO animation is directly set.setActive:animated:Set to be animated

@ Property (nonatomic, assign) id <UISearchDisplayDelegate> delegate

Proxy

@ Property (nonatomic, assign) BOOL displaysSearchBarInNavigationBar

The specified navigationbar contains a searchBar.

@ Property (nonatomic, readonly) UINavigationItem * navigationItem

The read-only attribute indicates searchdisplaycontroller in the navigationbar of the navigation controller;

@ Property (nonatomic, readonly) UISearchBar * searchBar

UISearchBar in UISearchDisplayController;

@ Property (nonatomic, readonly) UIViewController * searchContentsController

This attribute manages the searched content

@ Property (nonatomic, assign) id <UITableViewDataSource> searchResultsDataSource

Displays the data source of the search result.

@ Property (nonatomic, assign) id <UITableViewDelegate> searchResultsDelegate

Proxy of the table displayed in the search result

@ Property (nonatomic, readonly) UITableView * searchResultsTableView

Table displayed in the search result

@ Property (nonatomic, copy) NSString * searchResultsTitle

Title of the search result View

-(Id) initWithSearchBar :( UISearchBar *) searchBar contentsController :( UIViewController *) viewController

Initialize the search and view controller associated with the controller.

-(Void) setActive :( BOOL) visible animated :( BOOL) animated

Show or hide search View

Content from Apple documentation



Where are ios study notes? Is it suitable for self-developed ios?

If you do not need to enter the training institution, you can learn it. If you do not need to pay the money, you must learn it. However, it depends on whether you have the self-control ability.
IOS applications are 1.4 times more than Android, while system developers are 0.38 times more than Android. This shows that the talent gap in the iOS industry is quite large. Because of this, the market is extremely pressing for Objective-C and C ++ developers, making the two occupations quite positive in employment trends, finally, it pushed the iOS industry to stride into the sunrise industry. In the current market environment that is in short supply, the increase in iOS talent salary is much higher than that of Android.

The next 10 years will be the mobile Internet era. This conclusion has become a consensus in the industry.
1: deploying iOS applications is a required strategic choice for enterprises.
2: the involvement of large enterprises will aggravate the shortage of iOS Talents
3: Code workers are rejected in the iOS field. The so-called experts are not only proficient in technology, but also understand users, the market, and design. The iOS field is dominated by compound and innovative talents.

When the iOS developer UISearchDisplayController finds 3 or 5 items, the scrolling tableview is incorrect.

I don't quite understand what you mean. Do you want to scroll? Or is the data incorrect during scrolling?
 

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.