Git Product home page Git Product logo

uisearchcontrollerdemo's Introduction

UISearchController的基本使用

注意几个环节

1. 什么时候有导航栏,什么时候没有

搜索页,结果页,结果页跳转到的信息页

2. 初始化配置,eg
  self.resultController = [[SearchResultViewController alloc] initWithNibName:NSStringFromClass([SearchResultViewController class]) bundle:nil];
    
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.resultController];
    
    self.searchController = [[UISearchController alloc] initWithSearchResultsController:navigationController];
    
    self.searchController.searchResultsUpdater = self.resultController;
    self.searchController.delegate = self.resultController;
    self.searchController.hidesNavigationBarDuringPresentation = YES;
    self.tableView.tableHeaderView = self.searchController.searchBar;
    
    
    self.searchController.searchBar.delegate = self;
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = 44;

3. 何时退出搜索控制器

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
     NSLog(@"%s",__func__);
    
    // 可以在此处用来退出控制器,需要注意导航栏的时机无论是展示还是隐藏
    
}
4. result控制器操作,代理事件

- (void)willPresentSearchController:(UISearchController *)searchController
{
    NSLog(@"%s",__func__);
    self.searchController = searchController;
}

- (void)didPresentSearchController:(UISearchController *)searchController
{
     NSLog(@"%s",__func__);
}

- (void)willDismissSearchController:(UISearchController *)searchController
{
     NSLog(@"%s",__func__);
}
- (void)didDismissSearchController:(UISearchController *)searchController
{
     NSLog(@"%s",__func__);
}

- (void)presentSearchController:(UISearchController *)searchController
{
     NSLog(@"%s",__func__);
}

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController
{
     NSLog(@"%s",__func__);
}

其他注意事项看代码

其他

git 代码提交 '.' 不可以代表所有的提交,需要使用'*' , 这就与svn命令提交比较相似了,这一点稍微注意下。

uisearchcontrollerdemo's People

Contributors

linfengwenyou avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.