整理时间:2017年05月02日14:01:39
1.PYSearch介绍
一个非常优雅的搜索控制器iOS框架
2.PYSearch特性
- 支持各种热门搜索风格
- 支持多种搜索历史风格
- 支持各种搜索结果显示模式
- 支持搜索建议
- 支持搜索历史缓存
- 支持使用delegate或block完成搜索的回调
- 支持CocoaPods
- 支持多语言
- 支持横屏或者竖屏的iPhone或iPad
2.PYSearch源码地址
Github地址:
https://github.com/iphone5solo/PYSearch
3.PYSearch图片介绍
<img src="http:https://img.haomeiwen.com/i1247655/2a96ee3805238b59.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375"><img src="http:https://img.haomeiwen.com/i1247655/40dd214cbc789c25.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375">
<img src="http:https://img.haomeiwen.com/i1247655/d9e6e5ba5fe359f7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375">
<img src="http:https://img.haomeiwen.com/i1247655/51186998de4b36b3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375">
<img src="http:https://img.haomeiwen.com/i1247655/d4645568b6f9e944.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375"><img src="http:https://img.haomeiwen.com/i1247655/54681d5655bbcb74.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375">
<img src="http:https://img.haomeiwen.com/i1247655/dcbcd71a47b0410e.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375"><img src="http:https://img.haomeiwen.com/i1247655/8f4fb48140f70659.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375">
<img src="http:https://img.haomeiwen.com/i1247655/a091f6c8ac9a1ab4.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375"><img src="http:https://img.haomeiwen.com/i1247655/6ebfd457f6659504.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width="375">
3.安装教程
3.1cocoaPods安装
在项目中的Podfile文件中,添加
pod 'PYSearch'
然后终端进入项目根目录,输入
pod install --verbose --no-repo-update
如果要更新请使用
pod update --verbose --no-repo-update
在使用的时候导入头文件
#import <PYSearch.h>
4.SDK要求
该项目最低支持 Xcode 7.0
。
5.使用方法
5.1细节(详细请看原作者的demo)
// 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];
5.2自定义
5.2.1自定义搜索建议显示
// 1. Set dataSource
searchViewController.dataSource = self;
// 2. Implement dataSource method
5.2.2自定义搜索结果显示
// 1. Set searchResultShowMode
searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
// 2. Set searchResultController
searchViewController.searchResultController = [[UIViewController alloc] init];
5.2.3设置热门搜索(默认是 PYHotSearchStyleNormalTag)
// Set hotSearchStyle
searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag;
5.2.4设置搜索历史风格(默认是 PYSearchHistoryStyleCell)
// Set searchHistoryStyle
searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;
5.2.5设置搜索历史缓存路径(默认是 PYSEARCH_SEARCH_HISTORY_CACHE_PATH)
// Set searchHistoriesCachePath
searchViewController.searchHistoriesCachePath = @"The cache path";
5.2.5设置搜索历史条数(默认是 20条)
// Set searchHistoriesCount
searchViewController. searchHistoriesCount = 6;
5.2.6设置搜索结果显示模式(默认是 PYSearchResultShowModeCustom)
// Set searchResultShowMode
searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
5.2.7设置搜索建议显示(默认是 NO)
// Set searchSuggestionHidden
searchViewController.searchSuggestionHidden = YES;
网友评论