iOS 中用于多款优雅搜索风格的搜索控制器(支持 iPhone & iPad )

2017-03-20 09:47:41 +08:00
 CoderKo1o

PYSearch

Features

Requirements

Architecture

Main

Category

Contents

Renderings

Styles

Hot search style



Search history style



How to use

  • Use CocoaPods:
    • pod "PYSearch"
    • Import the main file :#import <PYSearch.h>
  • 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
// 1. Set dataSource
searchViewController.dataSource = self;
// 2. Implement dataSource method
  • Custom search result dispaly
// 1. Set searchResultShowMode
searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
// 2. Set searchResultController 
searchViewController.searchResultController = [[UIViewController alloc] init];
  • Set hotSearchStyle ( default is PYHotSearchStyleNormalTag )
// Set hotSearchStyle
searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag;
  • Set searchHistoryStyle ( default is PYSearchHistoryStyleCell )
// Set searchHistoryStyle
searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;
  • Set searchHistoriesCachePath ( default is PYSEARCH_SEARCH_HISTORY_CACHE_PATH )
// Set searchHistoriesCachePath
searchViewController.searchHistoriesCachePath = @"The cache path";
  • Set searchHistoriesCount ( default is 20 )
// Set searchHistoriesCount
searchViewController. searchHistoriesCount = 6;
  • Set searchResultShowMode ( default is PYSearchResultShowModeCustom )
// Set searchResultShowMode
searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
  • Set searchSuggestionHidden ( deafult is NO )
// 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:499491531@qq.com.
  • 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.

1638 次点击
所在节点    分享发现
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/348734

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX