zoukankan      html  css  js  c++  java
  • 自定义UISearchDisplayController的“No Results“标签和”Cancel“按钮

    本文转载至 http://www.cnblogs.com/pengyingh/articles/2350154.html

    - (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {

    UISearchBar *searchBar = self.searchDisplayController.searchBar;

    [searchBar setShowsCancelButton:YES animated:YES];

    for(UIView *subView in searchBar.subviews){

    if([subView isKindOfClass:UIButton.class]){

    [(UIButton*)subView setTitle:@"取消" forState:UIControlStateNormal];

    }

    }

    }

    No Results:

    - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString

    {

    [self filterContentForSearchText:searchString];

    if ([filteredListPinYin count] == 0) {

    UITableView *tableView1 = self.searchDisplayController.searchResultsTableView;

    for( UIView *subview in tableView1.subviews ) {

    if( [subview class] == [UILabel class] ) {

    UILabel *lbl = (UILabel*)subview; // sv changed to subview.

    lbl.text = @”没有结果”;

    }

    }

    }

    // Return YES to cause the search result table view to be reloaded.

    return YES;

    }

     
     
  • 相关阅读:
    分分钟制作微信朋友圈页面
    js模板引擎原理,附自己写的简洁模板引擎
    基于H5 pushState实现无跳转页面刷新
    随手学和记——PHP快速上手基础
    ES5 特性概览
    JavaScript错误和异常
    JavaScript闭包探究
    FastDFS总结
    C++11笔记
    leveldb源码笔记
  • 原文地址:https://www.cnblogs.com/Camier-myNiuer/p/4076486.html
Copyright © 2011-2022 走看看