|
@@ -8,19 +8,126 @@
|
|
|
|
|
|
#import "SearchBaseVC.h"
|
|
|
#import "SearchCell.h"
|
|
|
+#import "DrawerView.h"
|
|
|
+#import "InfoSearchView.h"
|
|
|
+#import "TabBarController.h"
|
|
|
|
|
|
-@interface SearchBaseVC ()<UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource>
|
|
|
-@property (strong, nonatomic) UISearchBar * searchBar;
|
|
|
-@property (strong, nonatomic) UIView * searchV;
|
|
|
-@property (strong, nonatomic) UIButton * backBtn;
|
|
|
-@property (strong, nonatomic) UIView * navBarV;
|
|
|
+@interface SearchBaseVC ()<UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,InfoSearchViewDelegate>
|
|
|
+//@property (strong, nonatomic) UISearchBar * searchBar;
|
|
|
+//@property (strong, nonatomic) UIView * searchV;
|
|
|
+//@property (strong, nonatomic) UIButton * backBtn;
|
|
|
+//@property (strong, nonatomic) UIButton * menuBtn;
|
|
|
+//@property (strong, nonatomic) UIView * navBarV;
|
|
|
@property (strong, nonatomic) UILabel * lineL;
|
|
|
@property (nonatomic, strong) NSMutableArray * dataDistoryArray;
|
|
|
+@property (strong,nonatomic) DrawerView *drawerView;
|
|
|
+@property (nonatomic, strong) InfoSearchView *topNavSearch;
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
@implementation SearchBaseVC
|
|
|
+- (InfoSearchView *)topNavSearch {
|
|
|
+ if (!_topNavSearch) {
|
|
|
+ _topNavSearch = [[InfoSearchView alloc] initWithFrame:CGRectMake(0, (IS_IPHONEX?40:20), kGXScreenWidth, 45) type:InfoSearchViewTypeDefault];
|
|
|
+ _topNavSearch.delegate = self;
|
|
|
+ WS(weakSelf);
|
|
|
+ _topNavSearch.backBlock = ^{
|
|
|
+ if (weakSelf.collectionView.isHidden) {
|
|
|
+ weakSelf.collectionView.hidden = NO;
|
|
|
+ weakSelf.noDataView.hidden = YES;
|
|
|
+ weakSelf.tableView.hidden = YES;
|
|
|
+ }else{
|
|
|
+ [weakSelf.navigationController popViewControllerAnimated:YES];
|
|
|
+ }
|
|
|
+ };
|
|
|
+ _topNavSearch.cancelBlock = ^{
|
|
|
+ if (weakSelf.cancelBlock) {
|
|
|
+ weakSelf.cancelBlock();
|
|
|
+ }
|
|
|
+ weakSelf.collectionView.hidden = NO;
|
|
|
+ weakSelf.noDataView.hidden = YES;
|
|
|
+ weakSelf.tableView.hidden = YES;
|
|
|
+ };
|
|
|
+// self.topNavSearch.backBlock = ^{
|
|
|
+// if (weakSelf.cancelBtn.isHidden) {
|
|
|
+// [weakSelf.navigationController popViewControllerAnimated:YES];
|
|
|
+// }else{
|
|
|
+// weakSelf.collectionView.hidden = NO;
|
|
|
+// weakSelf.noDataView.hidden = YES;
|
|
|
+// weakSelf.tableView.hidden = YES;
|
|
|
+// // [weakSelf upCanCelBtnConstraits];
|
|
|
+// }
|
|
|
+// };
|
|
|
+// self.topNavSearch.cancelBlock = ^{
|
|
|
+// // weakSelf.searchBar.text = @"";
|
|
|
+// weakSelf.collectionView.hidden = NO;
|
|
|
+// weakSelf.noDataView.hidden = YES;
|
|
|
+// weakSelf.tableView.hidden = YES;
|
|
|
+// // [weakSelf upCanCelBtnConstraits];
|
|
|
+// };
|
|
|
+ _topNavSearch.menuBlock = ^{
|
|
|
+ [weakSelf.view endEditing:YES];
|
|
|
+ [[UtilsTools getWindow] addSubview:weakSelf.drawerView];
|
|
|
+ weakSelf.drawerView.SelectDrawerBlock = ^(NSIndexPath * _Nonnull indexPath) {
|
|
|
+ if (![weakSelf.tabBarController isKindOfClass:[TabBarController class]]) {
|
|
|
+ [TabBarController sharedTabBarController].tabBar.hidden = NO;
|
|
|
+ [weakSelf.tabBarController.navigationController popViewControllerAnimated:NO];
|
|
|
+ }
|
|
|
+ if ([weakSelf.navigationController.viewControllers count] > 1) {
|
|
|
+ [weakSelf.navigationController popToRootViewControllerAnimated:NO];
|
|
|
+ }
|
|
|
+ switch (indexPath.section) {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ [[TabBarController sharedTabBarController] setSelectedIndex:indexPath.row];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ switch (indexPath.row) {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ [[TabBarController sharedTabBarController] setSelectedIndex:2];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ [[TabBarController sharedTabBarController] setSelectedIndex:2];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ [[TabBarController sharedTabBarController] setSelectedIndex:3];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:DRAWERPUSHVC object:nil userInfo:@{VCINDEX:@(indexPath.row)}];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ [[TabBarController sharedTabBarController] setSelectedIndex:3];
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:DRAWERPUSHVC object:nil userInfo:@{VCINDEX:@(4 + indexPath.row)}];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ weakSelf.drawerView.frame = CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT);// - kNavigationHeight
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return _topNavSearch;
|
|
|
+}
|
|
|
+-(DrawerView *)drawerView{
|
|
|
+ if(!_drawerView){
|
|
|
+ _drawerView = [[DrawerView alloc] init];
|
|
|
+ }
|
|
|
+ return _drawerView;
|
|
|
+}
|
|
|
- (UIView *)noDataView
|
|
|
{
|
|
|
if (!_noDataView) {
|
|
@@ -48,14 +155,22 @@
|
|
|
}
|
|
|
return _cancelBtn;
|
|
|
}
|
|
|
-- (UIButton *)backBtn
|
|
|
-{
|
|
|
- if (!_backBtn) {
|
|
|
- _backBtn = [UIButton new];
|
|
|
- [_backBtn setImage:IMG(@"back_black_icon") forState:UIControlStateNormal];
|
|
|
- }
|
|
|
- return _backBtn;
|
|
|
-}
|
|
|
+//- (UIButton *)backBtn
|
|
|
+//{
|
|
|
+// if (!_backBtn) {
|
|
|
+// _backBtn = [UIButton new];
|
|
|
+// [_backBtn setImage:IMG(@"back_black_icon") forState:UIControlStateNormal];
|
|
|
+// }
|
|
|
+// return _backBtn;
|
|
|
+//}
|
|
|
+//- (UIButton *)menuBtn
|
|
|
+//{
|
|
|
+// if (!_menuBtn) {
|
|
|
+// _menuBtn = [UIButton new];
|
|
|
+// [_menuBtn setImage:IMG(@"back_black_icon") forState:UIControlStateNormal];
|
|
|
+// }
|
|
|
+// return _menuBtn;
|
|
|
+//}
|
|
|
- (UILabel *)lineL
|
|
|
{
|
|
|
if (!_lineL) {
|
|
@@ -64,21 +179,21 @@
|
|
|
}
|
|
|
return _lineL;
|
|
|
}
|
|
|
-- (UIView *)navBarV
|
|
|
-{
|
|
|
- if (!_navBarV) {
|
|
|
- _navBarV = [UIView new];
|
|
|
- _navBarV.backgroundColor = [UIColor whiteColor];
|
|
|
- }
|
|
|
- return _navBarV;
|
|
|
-}
|
|
|
-- (UISearchBar *)searchBar
|
|
|
-{
|
|
|
- if (!_searchBar) {
|
|
|
- _searchBar = [UISearchBar new];
|
|
|
- }
|
|
|
- return _searchBar;
|
|
|
-}
|
|
|
+//- (UIView *)navBarV
|
|
|
+//{
|
|
|
+// if (!_navBarV) {
|
|
|
+// _navBarV = [UIView new];
|
|
|
+// _navBarV.backgroundColor = [UIColor whiteColor];
|
|
|
+// }
|
|
|
+// return _navBarV;
|
|
|
+//}
|
|
|
+//- (UISearchBar *)searchBar
|
|
|
+//{
|
|
|
+// if (!_searchBar) {
|
|
|
+// _searchBar = [UISearchBar new];
|
|
|
+// }
|
|
|
+// return _searchBar;
|
|
|
+//}
|
|
|
- (UICollectionView *)collectionView
|
|
|
{
|
|
|
if (!_collectionView) {
|
|
@@ -111,60 +226,65 @@
|
|
|
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headReusableView"];
|
|
|
self.collectionView.backgroundColor = [UIColor whiteColor];
|
|
|
self.view.backgroundColor = RGB(255, 255, 255);
|
|
|
- WS(weakSelf);
|
|
|
- [self.backBtn setAction:^{
|
|
|
- if (weakSelf.cancelBtn.isHidden) {
|
|
|
- [weakSelf.navigationController popViewControllerAnimated:YES];
|
|
|
- }else{
|
|
|
- weakSelf.collectionView.hidden = NO;
|
|
|
- weakSelf.noDataView.hidden = YES;
|
|
|
- weakSelf.tableView.hidden = YES;
|
|
|
- [weakSelf upCanCelBtnConstraits];
|
|
|
- }
|
|
|
- }];
|
|
|
- [self.cancelBtn setAction:^{
|
|
|
- weakSelf.searchBar.text = @"";
|
|
|
- weakSelf.collectionView.hidden = NO;
|
|
|
- weakSelf.noDataView.hidden = YES;
|
|
|
- weakSelf.tableView.hidden = YES;
|
|
|
- [weakSelf upCanCelBtnConstraits];
|
|
|
- }];
|
|
|
- [self.searchBar becomeFirstResponder];
|
|
|
+// [self.cancelBtn setAction:^{
|
|
|
+// weakSelf.searchBar.text = @"";
|
|
|
+// weakSelf.collectionView.hidden = NO;
|
|
|
+// weakSelf.noDataView.hidden = YES;
|
|
|
+// weakSelf.tableView.hidden = YES;
|
|
|
+// [weakSelf upCanCelBtnConstraits];
|
|
|
+// }];
|
|
|
+// [self.searchBar becomeFirstResponder];
|
|
|
}
|
|
|
- (void)setCusView
|
|
|
{
|
|
|
- [self.view addSubview:self.navBarV];
|
|
|
- [self.navBarV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.left.right.mas_equalTo(self.view);
|
|
|
- make.height.offset(IS_IPHONEX ? 84:64);
|
|
|
- }];
|
|
|
- [self.navBarV addSubview:self.backBtn];
|
|
|
- [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.bottom.mas_equalTo(self.navBarV);
|
|
|
- make.size.mas_offset(CGSizeMake(50, 44));
|
|
|
- }];
|
|
|
- [self.navBarV addSubview:self.cancelBtn];
|
|
|
- [self upCanCelBtnConstraits];
|
|
|
- [self.navBarV addSubview:self.searchBar];
|
|
|
- [self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_equalTo(self.backBtn.mas_right);
|
|
|
- make.centerY.mas_equalTo(self.backBtn);
|
|
|
- make.height.mas_offset(32);
|
|
|
- make.right.mas_equalTo(self.cancelBtn.mas_left).offset(-15);
|
|
|
- }];
|
|
|
- [self.navBarV addSubview:self.lineL];
|
|
|
+// [self.view addSubview:self.navBarV];
|
|
|
+// [self.navBarV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.top.left.right.mas_equalTo(self.view);
|
|
|
+// make.height.offset(IS_IPHONEX ? 84:64);
|
|
|
+// }];
|
|
|
+// [self.navBarV addSubview:self.backBtn];
|
|
|
+// [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.left.bottom.mas_equalTo(self.navBarV);
|
|
|
+// make.size.mas_offset(CGSizeMake(50, 44));
|
|
|
+// }];
|
|
|
+// [self.navBarV addSubview:self.menuBtn];
|
|
|
+// [self.menuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.bottom.mas_equalTo(self.navBarV);
|
|
|
+// make.left.mas_equalTo(self.backBtn.mas_right);
|
|
|
+// make.size.mas_offset(CGSizeMake(50, 44));
|
|
|
+// }];
|
|
|
+// [self.navBarV addSubview:self.cancelBtn];
|
|
|
+// [self upCanCelBtnConstraits];
|
|
|
+// [self.navBarV addSubview:self.searchBar];
|
|
|
+// [self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.left.mas_equalTo(self.backBtn.mas_right);
|
|
|
+// make.centerY.mas_equalTo(self.backBtn);
|
|
|
+// make.height.mas_offset(32);
|
|
|
+// make.right.mas_equalTo(self.cancelBtn.mas_left).offset(-15);
|
|
|
+// }];
|
|
|
+ [self.view addSubview:self.topNavSearch];
|
|
|
+ if (self.IsAddUser) {
|
|
|
+ CGRect rect = self.topNavSearch.searchBar.frame;
|
|
|
+ CGFloat w = rect.size.width - 60;
|
|
|
+ rect.size.width = w;
|
|
|
+ self.topNavSearch.searchBar.frame = rect;
|
|
|
+ [self.topNavSearch addSubview:self.cancelBtn];
|
|
|
+ [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(self.topNavSearch.searchBar.mas_right).offset(5);
|
|
|
+ make.top.bottom.mas_equalTo(self.topNavSearch.searchBar);
|
|
|
+ make.width.mas_offset(55);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ [self.view addSubview:self.lineL];
|
|
|
[self.lineL mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.bottom.right.mas_equalTo(self.navBarV);
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.topNavSearch.mas_bottom);
|
|
|
make.height.mas_offset(0.5);
|
|
|
}];
|
|
|
- self.searchBar.layer.borderWidth = 0.5f;
|
|
|
- self.searchBar.layer.cornerRadius = 3.f;
|
|
|
- self.searchBar.layer.borderColor = UIColorHex(#CCCCCC).CGColor;
|
|
|
- self.searchBar.layer.masksToBounds = YES;
|
|
|
[self.view addSubview:self.collectionView];
|
|
|
[self.view addSubview:self.tableView];
|
|
|
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.mas_equalTo(self.navBarV.mas_bottom);
|
|
|
+ make.top.mas_equalTo(self.lineL.mas_bottom);
|
|
|
make.left.right.mas_equalTo(self.view);
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
|
|
@@ -173,7 +293,7 @@
|
|
|
}
|
|
|
}];
|
|
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.mas_equalTo(self.navBarV.mas_bottom);
|
|
|
+ make.top.mas_equalTo(self.lineL.mas_bottom);
|
|
|
make.left.right.mas_equalTo(self.view);
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
|
|
@@ -184,7 +304,7 @@
|
|
|
[self.view addSubview:self.noDataView];
|
|
|
self.noDataView.hidden = YES;
|
|
|
[self.noDataView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.mas_equalTo(self.navBarV.mas_bottom);
|
|
|
+ make.top.mas_equalTo(self.lineL.mas_bottom);
|
|
|
make.left.right.mas_equalTo(self.view);
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
|
|
@@ -196,44 +316,44 @@
|
|
|
[self.noDataL mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.center.mas_equalTo(self.noDataView);
|
|
|
}];
|
|
|
- _searchBar.backgroundImage = [UtilsTools imageWithColor:[UIColor clearColor] size:_searchBar.bounds.size];
|
|
|
-
|
|
|
- UIImage* clearImg = [UtilsTools imageWithColor:[UIColor clearColor] andHeight:44.0f];
|
|
|
- [_searchBar setBackgroundImage:clearImg];
|
|
|
- [_searchBar setSearchFieldBackgroundImage:clearImg forState:UIControlStateNormal];
|
|
|
- [_searchBar setBackgroundColor:[UIColor clearColor]];
|
|
|
-
|
|
|
- [_searchV setBackgroundColor:[UIColor whiteColor]];
|
|
|
- [_searchV setRadius:4 borderColor:RGB(204, 204, 204) borderWidth:.5];
|
|
|
- self.searchBar.delegate = self;
|
|
|
-
|
|
|
- if ([UIDevice currentDevice].systemVersion.floatValue >= 13.0) {
|
|
|
- self.searchBar.searchTextField.font = [UIFont systemFontOfSize:14.0];
|
|
|
- if (!self.searchBar.searchTextField.placeholder) {
|
|
|
- self.searchBar.searchTextField.placeholder = @"搜索";
|
|
|
- }
|
|
|
- NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:self.searchBar.searchTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.searchBar.searchTextField.font}];
|
|
|
- self.searchBar.searchTextField.attributedPlaceholder = attrString;
|
|
|
- }else{
|
|
|
- for (UIView *view in self.searchBar.subviews.lastObject.subviews) {
|
|
|
- if([view isKindOfClass:NSClassFromString(@"UISearchBarTextField")]) {
|
|
|
- UITextField *textField = (UITextField *)view;
|
|
|
- //设置输入框的背景颜色
|
|
|
- textField.clipsToBounds = YES;
|
|
|
- //设置输入字体颜色
|
|
|
- textField.textColor = [UIColor blackColor];
|
|
|
- //设置默认文字颜色
|
|
|
- textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@" 搜索" attributes:@{NSForegroundColorAttributeName:[UIColor hexStringToColor:@"999999"]}];
|
|
|
- textField.font = [UIFont systemFontOfSize:14];
|
|
|
- for (UIView * subView in view.subviews) {
|
|
|
- if ([subView isKindOfClass:NSClassFromString(@"UIImageView")]) {
|
|
|
- UIImageView * imageV = (UIImageView *)subView;
|
|
|
- imageV.image = IMG(@"searchIcon");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// _searchBar.backgroundImage = [UtilsTools imageWithColor:[UIColor clearColor] size:_searchBar.bounds.size];
|
|
|
+//
|
|
|
+// UIImage* clearImg = [UtilsTools imageWithColor:[UIColor clearColor] andHeight:44.0f];
|
|
|
+// [_searchBar setBackgroundImage:clearImg];
|
|
|
+// [_searchBar setSearchFieldBackgroundImage:clearImg forState:UIControlStateNormal];
|
|
|
+// [_searchBar setBackgroundColor:[UIColor clearColor]];
|
|
|
+//
|
|
|
+// [_searchV setBackgroundColor:[UIColor whiteColor]];
|
|
|
+// [_searchV setRadius:4 borderColor:RGB(204, 204, 204) borderWidth:.5];
|
|
|
+// self.searchBar.delegate = self;
|
|
|
+//
|
|
|
+// if ([UIDevice currentDevice].systemVersion.floatValue >= 13.0) {
|
|
|
+// self.searchBar.searchTextField.font = [UIFont systemFontOfSize:14.0];
|
|
|
+// if (!self.searchBar.searchTextField.placeholder) {
|
|
|
+// self.searchBar.searchTextField.placeholder = @"搜索";
|
|
|
+// }
|
|
|
+// NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:self.searchBar.searchTextField.placeholder attributes: @{NSForegroundColorAttributeName:RGB(153, 153, 153), NSFontAttributeName:self.searchBar.searchTextField.font}];
|
|
|
+// self.searchBar.searchTextField.attributedPlaceholder = attrString;
|
|
|
+// }else{
|
|
|
+// for (UIView *view in self.searchBar.subviews.lastObject.subviews) {
|
|
|
+// if([view isKindOfClass:NSClassFromString(@"UISearchBarTextField")]) {
|
|
|
+// UITextField *textField = (UITextField *)view;
|
|
|
+// //设置输入框的背景颜色
|
|
|
+// textField.clipsToBounds = YES;
|
|
|
+// //设置输入字体颜色
|
|
|
+// textField.textColor = [UIColor blackColor];
|
|
|
+// //设置默认文字颜色
|
|
|
+// textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@" 搜索" attributes:@{NSForegroundColorAttributeName:[UIColor hexStringToColor:@"999999"]}];
|
|
|
+// textField.font = [UIFont systemFontOfSize:14];
|
|
|
+// for (UIView * subView in view.subviews) {
|
|
|
+// if ([subView isKindOfClass:NSClassFromString(@"UIImageView")]) {
|
|
|
+// UIImageView * imageV = (UIImageView *)subView;
|
|
|
+// imageV.image = IMG(@"searchIcon");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
- (NSMutableArray *)dataDistoryArray
|
|
|
{
|
|
@@ -273,7 +393,6 @@
|
|
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
|
|
|
[self selectIndexText:[self.dataDistoryArray objectAtIndex:indexPath.row]];
|
|
|
- [self showCancelBtn];
|
|
|
}
|
|
|
|
|
|
//footer的size
|
|
@@ -341,13 +460,20 @@
|
|
|
}
|
|
|
return nil;
|
|
|
}
|
|
|
-
|
|
|
+- (void)searchButtonAction:(UISearchBar *)searchBar {
|
|
|
+ if (searchBar.text.length > 0) {
|
|
|
+ [self selectIndexText:searchBar.text];
|
|
|
+ }
|
|
|
+}
|
|
|
- (void)selectIndexText:(NSString *)text
|
|
|
{
|
|
|
+ self.searchText = text;
|
|
|
self.tableView.hidden = NO;
|
|
|
self.collectionView.hidden = YES;
|
|
|
- self.searchBar.text = text;
|
|
|
- self.searchText = self.searchBar.text;
|
|
|
+ [self.view endEditing:YES];
|
|
|
+ if (self.searchBlock) {
|
|
|
+ self.searchBlock(text);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)checkRepeatString:(NSString *)string {
|
|
@@ -371,45 +497,47 @@
|
|
|
if (searchBar.text.length > 0) {
|
|
|
[self selectIndexText:searchBar.text];
|
|
|
[self checkRepeatString:searchBar.text];
|
|
|
- [self showCancelBtn];
|
|
|
- }
|
|
|
-}
|
|
|
-- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
|
|
|
-
|
|
|
-}
|
|
|
-- (void)searchBarTextDidBeginEditing:(UISearchBar *) searchBar{
|
|
|
- UITextField *searchBarTextField = nil;
|
|
|
- NSArray *views = ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0) ? searchBar.subviews : [[searchBar.subviews objectAtIndex:0] subviews];
|
|
|
-
|
|
|
- for (UIView *subview in views){
|
|
|
- if ([subview isKindOfClass:[UITextField class]]){
|
|
|
- searchBarTextField = (UITextField *)subview;
|
|
|
- break;
|
|
|
- }
|
|
|
+// [self showCancelBtn];
|
|
|
}
|
|
|
- searchBarTextField.enablesReturnKeyAutomatically = NO;
|
|
|
}
|
|
|
-- (void)showCancelBtn
|
|
|
-{
|
|
|
- if (self.cancelBtn.hidden) {
|
|
|
- self.cancelBtn.hidden = NO;
|
|
|
- [self.cancelBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.right.mas_equalTo(self.navBarV.mas_right).offset(-15);
|
|
|
- make.centerY.mas_equalTo(self.backBtn);
|
|
|
- }];
|
|
|
+- (void)textDidChange:(NSString *)text {
|
|
|
+ if (text.length > 0) {
|
|
|
+ [self selectIndexText:text];
|
|
|
}
|
|
|
}
|
|
|
-- (void)upCanCelBtnConstraits
|
|
|
-{
|
|
|
- self.cancelBtn.hidden = YES;
|
|
|
- [self.cancelBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.right.mas_equalTo(self.navBarV.mas_right);
|
|
|
- make.centerY.mas_equalTo(self.backBtn);
|
|
|
- make.width.mas_offset(0);
|
|
|
- }];
|
|
|
-}
|
|
|
-- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope{
|
|
|
- NSLog(@"%@1",searchBar.text);
|
|
|
-}
|
|
|
+//- (void)searchBarTextDidBeginEditing:(UISearchBar *) searchBar{
|
|
|
+// UITextField *searchBarTextField = nil;
|
|
|
+// NSArray *views = ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0) ? searchBar.subviews : [[searchBar.subviews objectAtIndex:0] subviews];
|
|
|
+//
|
|
|
+// for (UIView *subview in views){
|
|
|
+// if ([subview isKindOfClass:[UITextField class]]){
|
|
|
+// searchBarTextField = (UITextField *)subview;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// searchBarTextField.enablesReturnKeyAutomatically = NO;
|
|
|
+//}
|
|
|
+//- (void)showCancelBtn
|
|
|
+//{
|
|
|
+// if (self.cancelBtn.hidden) {
|
|
|
+// self.cancelBtn.hidden = NO;
|
|
|
+// [self.cancelBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.right.mas_equalTo(self.navBarV.mas_right).offset(-15);
|
|
|
+// make.centerY.mas_equalTo(self.backBtn);
|
|
|
+// }];
|
|
|
+// }
|
|
|
+//}
|
|
|
+//- (void)upCanCelBtnConstraits
|
|
|
+//{
|
|
|
+// self.cancelBtn.hidden = YES;
|
|
|
+// [self.cancelBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.right.mas_equalTo(self.navBarV.mas_right);
|
|
|
+// make.centerY.mas_equalTo(self.backBtn);
|
|
|
+// make.width.mas_offset(0);
|
|
|
+// }];
|
|
|
+//}
|
|
|
+//- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope{
|
|
|
+// NSLog(@"%@1",searchBar.text);
|
|
|
+//}
|
|
|
|
|
|
@end
|