zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
//  PBIssueSearchController.m
//  IphoneBIMe
//
//  Created by zjf on 2018/8/13.
//  Copyright © 2018年 ProBIM. All rights reserved.
//
 
#import "PBIssueSearchController.h"
 
@interface PBIssueSearchController ()<UISearchBarDelegate>
@property (nonatomic, strong) UISearchBar *searchBar;
@property (nonatomic, strong) UIButton *maskBtn;
@end
 
@implementation PBIssueSearchController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
}
- (void)setupNav {
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"whileNav"] forBarMetrics:UIBarMetricsDefault];
    self.searchBar = [[UISearchBar alloc] init];
    self.searchBar.placeholder = @"输入问题标题";
    self.searchBar.delegate = self;
    self.searchBar.returnKeyType=UIReturnKeySearch;
    self.searchBar.searchBarStyle = UISearchBarStyleMinimal;
    self.navigationItem.titleView = self.searchBar;
    [self.searchBar setShowsCancelButton:YES];
//    UIButton *cancelBtn = [self.searchBar valueForKey:@"cancelButton"];
//    self.cancelBtn = cancelBtn;
    self.navigationItem.hidesBackButton = YES;
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.right.bottom.equalTo(self.view);
    }];
}
//- (void)setupNav {
//    self.searchText = @"";
//    self.view.backgroundColor = [UIColor whiteColor];
//    self.navigationItem.hidesBackButton = YES;
//    self.searchBar = [[UISearchBar alloc] init];
//    self.searchBar.searchBarStyle = UISearchBarStyleMinimal;
//    self.searchBar.placeholder = @"搜索问题";
//    self.searchBar.delegate = self;
//    self.navigationItem.titleView = self.searchBar;
//    [self.searchBar becomeFirstResponder];
//
//    UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStyleDone target:self action:@selector(cancelAction)];
//    self.navigationItem.rightBarButtonItem = cancelItem;
//
//    self.countL = [UILabel z_labelWithText:@"搜索结果" Color:DescColor isBold:NO Font:16];
//    self.countL.frame = CGRectMake(20, 0, self.view.width - 40, 40);
//    [self.view addSubview:self.countL];
//    self.countL.hidden = YES;
//
//    CGFloat insetBottom;
//    if (IS_IPHONE_X) {
//        insetBottom = 34.f;
//    }else {
//        insetBottom = 0.f;
//    }
//    self.tableView.mj_footer.ignoredScrollViewContentInsetBottom =  insetBottom;
//}
 
#pragma mark - UISearchBarDelegate
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
    [self.searchBar resignFirstResponder];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    NSString *search = [searchBar.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    if ([search isEqualToString:@""]){
        return;
    }
    [self loadIssueListWithTitle:searchBar.text];
    [self.searchBar resignFirstResponder];
}
 
- (void)loadIssueListWithTitle:(NSString *)title {
    if ([title isEqualToString:@""]) {
        self.issueArrM = nil;
        [self.tableView reloadData];
        return;
    }
    self.searchText = title;
    [self.tableView.mj_header beginRefreshing];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
/*
#pragma mark - Navigation
 
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
 
@end