PYSearch

by ko1o

ko1o /PYSearch

­čöŹ An elegant search controller which replaces the UISearchController for iOS (iPhone & iPad) .

3.7K Stars 755 Forks Last release: almost 2 years ago (0.9.1) MIT License 164 Commits 50 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:



Apps Using Total Downloads
Build Status Pod Version Pod Platform Pod License

  • ­čöŹ An elegant search controller for iOS.

QQ chat room

 

Features

  • [x] Support a variety of hot search style
  • [x] Support a variety of search history style
  • [x] Support a variety of search results display mode
  • [x] Support a variety of search view controller display mode
  • [x] Support search suggestions
  • [x] Support search history (record) cache
  • [x] Support callback using delegate or block completion search
  • [x] Support CocoaPods
  • [x] Support localization
  • [x] Support vertical and horizontal screen on iPhone and iPad

Requirements

  • iOS 7.0 or later
  • Xcode 7.0 or later

Architecture

Main

  • PYSearch
  • PYSearchConst
  • PYSearchViewController
  • PYSearchSuggestionViewController

Category

  • UIColor+PYSearchExtension
  • UIView+PYSearchExtension
  • NSBundle+PYSearchExtension

Contents

Renderings

Styles

Hot search style



Search history style



How to use

  • Use CocoaPods:
    • pod "PYSearch"
    • Import the main file´╝Ü
      #import 
  • Manual import´╝Ü
    • Drag All files in the
      PYSearch
      folder to project
    • Import the main file´╝Ü
      #import "PYSearch.h"

Details (See the example program PYSearchExample for details)

    // 1. Create hotSearches array
    NSArray *hotSeaches = @[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"C#", @"Perl", @"Go", @"JavaScript", @"R", @"Ruby", @"MATLAB"];
    // 2. Create searchViewController
    PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:hotSeaches searchBarPlaceholder:@"Search programming language" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) {
        // Call this Block when completion search automatically
        // Such as: Push to a view controller
        [searchViewController.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];

}];
// 3. present the searchViewController
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchViewController];
[self presentViewController:nav  animated:NO completion:nil];

Custom

  • Custom search suggestions display

    objc
    // 1. Set dataSource
    searchViewController.dataSource = self;
    // 2. Implement dataSource method
    
  • Custom search result dispaly

    objc
    // 1. Set searchResultShowMode
    searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
    // 2. Set searchResultController 
    searchViewController.searchResultController = [[UIViewController alloc] init];
    
  • Set hotSearchStyle´╝łdefault is PYHotSearchStyleNormalTag´╝ë

    objc
    // Set hotSearchStyle
    searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag;
    
  • Set searchHistoryStyle´╝łdefault is PYSearchHistoryStyleCell´╝ë

    objc
    // Set searchHistoryStyle
    searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;
    
  • Set searchHistoriesCachePath´╝łdefault is PYSEARCHSEARCHHISTORYCACHEPATH´╝ë

    objc
    // Set searchHistoriesCachePath
    searchViewController.searchHistoriesCachePath = @"The cache path";
    
  • Set searchHistoriesCount´╝łdefault is 20´╝ë

    objc
    // Set searchHistoriesCount
    searchViewController. searchHistoriesCount = 6;
    
  • Set searchResultShowMode´╝łdefault is PYSearchResultShowModeCustom´╝ë

    objc
    // Set searchResultShowMode
    searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
    
  • Set searchSuggestionHidden´╝łdeafult is NO´╝ë

    objc
    // Set searchSuggestionHidden
    searchViewController.searchSuggestionHidden = YES;
    

Hope

  • If you have any questions during the process or want more interfaces to customize´╝îyou can issues me!
  • Instead of giving me star, it is better to throw a bug to me!
  • If you want to participate in the maintenance of this project or have a good design style, welcome to pull request!
  • If you feel slightly discomfort in use, please contact me QQ:499491531 or Email:[email protected]
  • Hope to improve this project together, let it become more powerful, able to meet the needs of most users!

Licenses

All source code is licensed under the MIT License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.