Skip to content

Commit de5bbf2

Browse files
committed
冒泡搜索 - 移动到「热门话题」页面
1 parent 3c9639b commit de5bbf2

File tree

5 files changed

+62
-129
lines changed

5 files changed

+62
-129
lines changed

Coding_iOS/Controllers/AllSearchDisplayVC.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ @interface AllSearchDisplayVC () <UISearchBarDelegate, UITableViewDelegate, UITa
5252
@property (nonatomic, strong) PublicSearchModel *searchPros;
5353
@property (nonatomic, strong) UIScrollView *searchHistoryView;
5454
@property (nonatomic, assign) double historyHeight;
55-
- (void)initSubViewsInContentView;
5655
- (void)initSearchResultsTableView;
5756
- (void)initSearchHistoryView;
5857
- (void)didClickedMoreHotkey:(UIGestureRecognizer *)sender;

Coding_iOS/Controllers/RootControllers/Tweet_RootViewController.m

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@
2525
#import "TweetSendLocationDetailViewController.h"
2626
#import "CodingBannersView.h"
2727

28-
#import "CSSearchVC.h"
29-
#import "CSSearchDisplayVC.h"
3028
#import "FunctionTipsManager.h"
3129
#import "CSHotTopicPagesVC.h"
3230

33-
@interface Tweet_RootViewController () <UISearchBarDelegate, UISearchDisplayDelegate>
31+
@interface Tweet_RootViewController ()
3432
{
3533
CGFloat _oldPanOffsetY;
3634
}
@@ -50,9 +48,6 @@ @interface Tweet_RootViewController () <UISearchBarDelegate, UISearchDisplayDele
5048
@property (strong, nonatomic) Tweet *deleteTweet;
5149
@property (nonatomic, assign) NSInteger deleteTweetsIndex;
5250

53-
//搜索
54-
@property (nonatomic, strong) UISearchBar *searchBar;
55-
@property (strong, nonatomic) CSSearchDisplayVC *searchDisplayVC;
5651
//Banner
5752
@property (strong, nonatomic) CodingBannersView *myBannersView;
5853
@end
@@ -104,7 +99,6 @@ - (void)viewDidLoad
10499
// [self refreshFirst];
105100
// }];
106101

107-
// UIBarButtonItem *leftBarItem =[UIBarButtonItem itemWithIcon:@"search_Nav" showBadge:NO target:self action:@selector(searchItemClicked:)];
108102
UIBarButtonItem *leftBarItem =[UIBarButtonItem itemWithIcon:@"hot_topic_Nav" showBadge:NO target:self action:@selector(hotTopicBtnClicked:)];
109103

110104
[self.parentViewController.navigationItem setLeftBarButtonItem:leftBarItem animated:NO];
@@ -297,48 +291,6 @@ - (void)hotTopicBtnClicked:(id)sender{
297291
[self.navigationController pushViewController:vc animated:YES];
298292
}
299293

300-
- (void)searchItemClicked:(id)sender{
301-
if ([[FunctionTipsManager shareManager] needToTip:kFunctionTipStr_Search]) {
302-
[[FunctionTipsManager shareManager] markTiped:kFunctionTipStr_Search];
303-
UIButton *leftItemView = (UIButton *)self.parentViewController.navigationItem.leftBarButtonItem.customView;
304-
[leftItemView removeBadgePoint];
305-
}
306-
307-
if(!_searchBar) {
308-
309-
_searchBar = ({
310-
311-
UISearchBar *searchBar = [[UISearchBar alloc] init];
312-
searchBar.delegate = self;
313-
[searchBar sizeToFit];
314-
[searchBar setPlaceholder:@"搜索冒泡、用户名、话题"];
315-
[searchBar setTintColor:[UIColor whiteColor]];
316-
[searchBar setTranslucent:NO];
317-
[searchBar insertBGColor:[UIColor colorWithHexString:@"0x28303b"]];
318-
searchBar;
319-
});
320-
[self.parentViewController.navigationController.view addSubview:_searchBar];
321-
[_searchBar setY:20];
322-
}
323-
324-
if (!_searchDisplayVC) {
325-
_searchDisplayVC = ({
326-
327-
CSSearchDisplayVC *searchVC = [[CSSearchDisplayVC alloc] initWithSearchBar:_searchBar contentsController:self.parentViewController];
328-
searchVC.parentVC = self;
329-
// searchVC.delegate = self;
330-
// if (kHigher_iOS_6_1) {
331-
//
332-
// searchVC.displaysSearchBarInNavigationBar = NO;
333-
// }
334-
searchVC;
335-
});
336-
}
337-
338-
[self hideToolBar:YES];
339-
[_searchBar becomeFirstResponder];
340-
}
341-
342294
#pragma mark Refresh M
343295

344296
- (void)refreshFirst{
@@ -610,36 +562,4 @@ - (void)dealloc
610562
_myTableView.dataSource = nil;
611563
}
612564

613-
#pragma mark -
614-
#pragma mark UISearchBarDelegate Support
615-
616-
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
617-
618-
return YES;
619-
}
620-
621-
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
622-
623-
}
624-
625-
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
626-
627-
}
628-
629-
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
630-
631-
[self hideToolBar:NO];
632-
}
633-
634-
#pragma mark -
635-
#pragma mark UISearchDisplayDelegate Support
636-
637-
- (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView {
638-
639-
}
640-
641-
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
642-
643-
}
644-
645565
@end

Coding_iOS/Controllers/Search/CSSearchDisplayVC.m

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ @interface CSSearchDisplayVC () <UISearchBarDelegate, UITableViewDelegate, UITab
4949
- (void)initSubViewsInContentView;
5050
- (void)initSearchResultsTableView;
5151
- (void)initSearchHistoryView;
52-
- (void)didClickedMoreHotkey:(UIGestureRecognizer *)sender;
5352
- (void)didCLickedCleanSearchHistory:(id)sender;
5453
- (void)didClickedContentView:(UIGestureRecognizer *)sender;
5554
- (void)didClickedHistory:(UIGestureRecognizer *)sender;
@@ -125,9 +124,9 @@ - (void)setActive:(BOOL)visible animated:(BOOL)animated {
125124
// [self.searchBar.superview addSubview:_backgroundView];
126125
// [self.searchBar.superview addSubview:_contentView];
127126
// [self.searchBar.superview bringSubviewToFront:_contentView];
128-
[self.parentVC.parentViewController.view addSubview:_backgroundView];
129-
[self.parentVC.parentViewController.view addSubview:_contentView];
130-
[self.parentVC.parentViewController.view bringSubviewToFront:_contentView];
127+
[self.parentVC.view addSubview:_backgroundView];
128+
[self.parentVC.view addSubview:_contentView];
129+
[self.parentVC.view bringSubviewToFront:_contentView];
131130
__weak typeof(self) weakSelf = self;
132131
self.searchBar.delegate = weakSelf;
133132
}
@@ -137,26 +136,9 @@ - (void)setActive:(BOOL)visible animated:(BOOL)animated {
137136
#pragma mark Private Method
138137

139138
- (void)initSubViewsInContentView {
140-
141-
UILabel *lblHotKey = [[UILabel alloc] initWithFrame:CGRectMake(12.0f, 4.0f, kScreen_Width, 39.0f)];
142-
[lblHotKey setUserInteractionEnabled:YES];
143-
[lblHotKey setText:@"热门话题"];
144-
[lblHotKey setFont:[UIFont systemFontOfSize:12.0f]];
145-
[lblHotKey setTextColor:[UIColor colorWithHexString:@"0x999999"]];
146-
[_contentView addSubview:lblHotKey];
147-
148-
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickedMoreHotkey:)];
149-
[lblHotKey addGestureRecognizer:tapGestureRecognizer];
150-
151-
UIImageView *moreIconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 10.0f, 20.0f, 20.0f)];
152-
moreIconView.image = [UIImage imageNamed:@"me_info_arrow_left"];
153-
moreIconView.right = kScreen_Width - 12;
154-
moreIconView.centerY = lblHotKey.centerY;
155-
[_contentView addSubview:moreIconView];
156-
157139
__weak typeof(self) weakSelf = self;
158140

159-
_topicHotkeyView = [[TopicHotkeyView alloc] initWithFrame:CGRectMake(0, 44, kScreen_Width, 0)];
141+
_topicHotkeyView = [[TopicHotkeyView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 0)];
160142
_topicHotkeyView.block = ^(NSDictionary *dict){
161143
[weakSelf.searchBar resignFirstResponder];
162144

@@ -168,7 +150,7 @@ - (void)initSubViewsInContentView {
168150
[_contentView addSubview:_topicHotkeyView];
169151
[_topicHotkeyView mas_makeConstraints:^(MASConstraintMaker *make) {
170152
make.left.mas_equalTo(@0);
171-
make.top.mas_equalTo(@44);
153+
make.top.mas_equalTo(@0);
172154
make.width.mas_equalTo(kScreen_Width);
173155
make.height.mas_equalTo(@0);
174156
}];
@@ -188,9 +170,6 @@ - (void)initSubViewsInContentView {
188170

189171
[weakSelf.topicHotkeyView setHotkeys:hotkeyArray];
190172
[weakSelf.topicHotkeyView mas_updateConstraints:^(MASConstraintMaker *make) {
191-
make.left.mas_equalTo(@0);
192-
make.top.mas_equalTo(@44);
193-
make.width.mas_equalTo(kScreen_Width);
194173
make.height.mas_equalTo(weakSelf.topicHotkeyView.frame.size.height);
195174
}];
196175
}
@@ -220,7 +199,7 @@ - (void)initSearchResultsTableView {
220199
}];
221200
}
222201

223-
[self.parentVC.parentViewController.view addSubview:tableView];
202+
[self.parentVC.view addSubview:tableView];
224203

225204
self.headerLabel = ({
226205
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 2, kScreen_Width, 44)];
@@ -244,10 +223,6 @@ - (void)initSearchResultsTableView {
244223
});
245224
}
246225
[_searchTableView.superview bringSubviewToFront:_searchTableView];
247-
// [self.searchBar.superview bringSubviewToFront:_searchTableView];
248-
249-
// _refreshControl = [[ODRefreshControl alloc] initInScrollView:self.searchTableView];
250-
// [_refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
251226

252227
[_searchTableView reloadData];
253228
[self refresh];
@@ -331,14 +306,6 @@ - (void)initSearchHistoryView {
331306

332307
}
333308

334-
- (void)didClickedMoreHotkey:(UIGestureRecognizer *)sender {
335-
[self.searchBar resignFirstResponder];
336-
337-
CSHotTopicPagesVC *vc = [CSHotTopicPagesVC new];
338-
[self.parentVC.navigationController pushViewController:vc animated:YES];
339-
340-
}
341-
342309
- (void)didCLickedCleanSearchHistory:(id)sender {
343310

344311
[CSSearchModel cleanAllSearchHistory];
@@ -419,11 +386,11 @@ - (void)analyseLinkStr:(NSString *)linkStr{
419386
}
420387
UIViewController *vc = [BaseViewController analyseVCFromLinkStr:linkStr];
421388
if (vc) {
422-
[self.parentVC.parentViewController.navigationController pushViewController:vc animated:YES];
389+
[self.parentVC.navigationController pushViewController:vc animated:YES];
423390
}else{
424391
//网页
425392
WebViewController *webVc = [WebViewController webVCWithUrlStr:linkStr];
426-
[self.parentVC.parentViewController.navigationController pushViewController:webVc animated:YES];
393+
[self.parentVC.navigationController pushViewController:webVc animated:YES];
427394
}
428395
}
429396

@@ -462,7 +429,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
462429
cell.userBtnClickedBlock = ^(User *curUser){
463430
UserInfoViewController *vc = [[UserInfoViewController alloc] init];
464431
vc.curUser = curUser;
465-
[self.parentVC.parentViewController.navigationController pushViewController:vc animated:YES];
432+
[self.parentVC.navigationController pushViewController:vc animated:YES];
466433
};
467434
cell.mediaItemClickedBlock = ^(HtmlMediaItem *curItem){
468435
[weakSelf analyseLinkStr:curItem.href];
@@ -485,7 +452,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
485452
vc.curTweet = tweet;
486453
vc.deleteTweetBlock = ^(Tweet *toDeleteTweet){
487454
};
488-
[self.parentVC.parentViewController.navigationController pushViewController:vc animated:YES];
455+
[self.parentVC.navigationController pushViewController:vc animated:YES];
489456

490457
}
491458

Coding_iOS/Controllers/Topic/CSHotTopicPagesVC.m

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@
1111
#import "CSHotTopicView.h"
1212
#import "CSMyTopicVC.h"
1313
#import "SMPageControl.h"
14+
#import "CSSearchVC.h"
15+
#import "CSSearchDisplayVC.h"
1416

15-
@interface CSHotTopicPagesVC ()<UIScrollViewDelegate>
17+
@interface CSHotTopicPagesVC ()<UIScrollViewDelegate, UISearchBarDelegate, UISearchDisplayDelegate>
1618
@property (nonatomic,strong) UIScrollView *scrollView;
1719
@property (nonatomic,strong) SMPageControl *pageControl;
1820
@property (nonatomic,strong) UIView *navigationBarView;
1921

2022
@property (nonatomic,strong)NSArray *navTitles;
23+
//搜索
24+
@property (nonatomic, strong) UISearchBar *searchBar;
25+
@property (strong, nonatomic) CSSearchDisplayVC *searchDisplayVC;
2126
@end
2227

2328
@implementation CSHotTopicPagesVC
@@ -26,7 +31,9 @@ @implementation CSHotTopicPagesVC
2631
- (void)viewDidLoad {
2732
[super viewDidLoad];
2833

29-
34+
UIBarButtonItem *rightBarItem =[UIBarButtonItem itemWithIcon:@"search_Nav" showBadge:NO target:self action:@selector(searchItemClicked:)];
35+
[self.navigationItem setRightBarButtonItem:rightBarItem animated:NO];
36+
3037
[self setupUI];
3138
}
3239

@@ -46,6 +53,46 @@ -(void)viewWillDisappear:(BOOL)animated{
4653
[self.navigationBarView removeFromSuperview];
4754
}
4855

56+
#pragma mark -
57+
- (void)searchItemClicked:(id)sender{
58+
59+
if(!_searchBar) {
60+
61+
_searchBar = ({
62+
63+
UISearchBar *searchBar = [[UISearchBar alloc] init];
64+
searchBar.delegate = self;
65+
[searchBar sizeToFit];
66+
[searchBar setPlaceholder:@"搜索冒泡、用户名、话题"];
67+
[searchBar setTintColor:[UIColor whiteColor]];
68+
[searchBar setTranslucent:NO];
69+
[searchBar insertBGColor:[UIColor colorWithHexString:@"0x28303b"]];
70+
searchBar;
71+
});
72+
[self.navigationController.view addSubview:_searchBar];
73+
[_searchBar setY:20];
74+
}
75+
76+
if (!_searchDisplayVC) {
77+
_searchDisplayVC = ({
78+
CSSearchDisplayVC *searchVC = [[CSSearchDisplayVC alloc] initWithSearchBar:_searchBar contentsController:self];
79+
searchVC.parentVC = self;
80+
searchVC.delegate = self;
81+
searchVC.displaysSearchBarInNavigationBar = NO;
82+
searchVC;
83+
});
84+
}
85+
86+
[_searchBar becomeFirstResponder];
87+
}
88+
89+
#pragma mark -
90+
#pragma mark UISearchBarDelegate Support
91+
92+
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
93+
94+
return YES;
95+
}
4996

5097
#pragma mark -
5198

Coding_iOS/Views/Search/TopicHotkeyView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ - (void)setHotkeys:(NSArray *)hotkeys {
4343
if(hotkeys.count) {
4444

4545
CGFloat currentWidth = 10.0f;
46-
CGFloat currentHeight = 0.0f;
46+
CGFloat currentHeight = 15.0f;
4747
CGSize currentSize = CGSizeZero;
4848
CGFloat maxWidth = kScreen_Width - 20.0f;
4949
UIFont *hotkeyFont = [UIFont systemFontOfSize:12.0f];
@@ -99,7 +99,7 @@ - (void)setHotkeys:(NSArray *)hotkeys {
9999

100100
if(i == hotkeys.count - 1) {
101101

102-
currentHeight += currentSize.height + 14.0f;
102+
currentHeight += currentSize.height + 15.0f;
103103
}
104104

105105
[self addSubview:btnHotkey];

0 commit comments

Comments
 (0)