Skip to content

Commit 7be10d9

Browse files
author
panshiyu
committed
d2 bugfix
1 parent b72bfd4 commit 7be10d9

16 files changed

Lines changed: 87 additions & 133 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,6 @@
769769
FE4CB43B1B618A6A0041E9EF /* CSTopicDetailVC.m in Sources */ = {isa = PBXBuildFile; fileRef = FE4CB43A1B618A6A0041E9EF /* CSTopicDetailVC.m */; };
770770
FE4CB43D1B618EDC0041E9EF /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = FE4CB43C1B618EDC0041E9EF /* [email protected] */; };
771771
FE4CB4401B6194D10041E9EF /* CSTopiclistView.m in Sources */ = {isa = PBXBuildFile; fileRef = FE4CB43F1B6194D10041E9EF /* CSTopiclistView.m */; };
772-
FE4CB4431B619D280041E9EF /* CSTopic.m in Sources */ = {isa = PBXBuildFile; fileRef = FE4CB4421B619D280041E9EF /* CSTopic.m */; };
773772
FE4CB4461B6566260041E9EF /* CSTopicHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = FE4CB4451B6566260041E9EF /* CSTopicHeaderView.m */; };
774773
FE4CB4491B65892F0041E9EF /* CSLikesVC.m in Sources */ = {isa = PBXBuildFile; fileRef = FE4CB4481B65892F0041E9EF /* CSLikesVC.m */; };
775774
FE4CB44B1B65ABA00041E9EF /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = FE4CB44A1B65ABA00041E9EF /* [email protected] */; };
@@ -1963,8 +1962,6 @@
19631962
FE4CB43C1B618EDC0041E9EF /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
19641963
FE4CB43E1B6194D10041E9EF /* CSTopiclistView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSTopiclistView.h; sourceTree = "<group>"; };
19651964
FE4CB43F1B6194D10041E9EF /* CSTopiclistView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSTopiclistView.m; sourceTree = "<group>"; };
1966-
FE4CB4411B619D280041E9EF /* CSTopic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSTopic.h; sourceTree = "<group>"; };
1967-
FE4CB4421B619D280041E9EF /* CSTopic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSTopic.m; sourceTree = "<group>"; };
19681965
FE4CB4441B6566260041E9EF /* CSTopicHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSTopicHeaderView.h; sourceTree = "<group>"; };
19691966
FE4CB4451B6566260041E9EF /* CSTopicHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSTopicHeaderView.m; sourceTree = "<group>"; };
19701967
FE4CB4471B65892F0041E9EF /* CSLikesVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSLikesVC.h; sourceTree = "<group>"; };
@@ -3532,8 +3529,6 @@
35323529
8EA6CFF319E240C40076D59C /* Tweets.m */,
35333530
4ECD72ED1AAD7EC300D69AE1 /* Tweet.h */,
35343531
4ECD72EE1AAD7EC300D69AE1 /* Tweet.m */,
3535-
FE4CB4411B619D280041E9EF /* CSTopic.h */,
3536-
FE4CB4421B619D280041E9EF /* CSTopic.m */,
35373532
8EA6CFF619E240C40076D59C /* User.h */,
35383533
8EA6CFF719E240C40076D59C /* User.m */,
35393534
8EA6CFF819E240C40076D59C /* Users.h */,
@@ -4720,7 +4715,6 @@
47204715
4E6BA2D91A1EE6AF005FD721 /* AFURLConnectionOperation.m in Sources */,
47214716
8EA6D1BB19E240C40076D59C /* ProjectTopic.m in Sources */,
47224717
8EA6D13219E240C40076D59C /* RegisterViewController.m in Sources */,
4723-
FE4CB4431B619D280041E9EF /* CSTopic.m in Sources */,
47244718
8EF643C519FF7E2900F7EEB0 /* TitleRImageMoreCell.m in Sources */,
47254719
4E217F151A70EDC700F6DF88 /* SVWebViewControllerActivitySafari.m in Sources */,
47264720
4E8D5D5A1B45295D00B70936 /* HOTPGenerator.m in Sources */,

Coding_iOS/Controllers/Search/CSSearchDisplayVC.m

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
#import "WebViewController.h"
2323
#import "TweetDetailViewController.h"
2424

25+
#import "CSTopicDetailVC.h"
26+
2527
#define kCellIdentifier_Search @"com.coding.search.tweet.result"
2628

27-
@interface CSSearchDisplayVC () <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource,TopicHotkeyViewDelegate>
29+
@interface CSSearchDisplayVC () <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource>
2830

2931
@property (nonatomic, strong) UIView *contentView;
3032
@property (nonatomic, strong) XHRealTimeBlur *backgroundView;
@@ -109,6 +111,7 @@ - (void)setActive:(BOOL)visible animated:(BOOL)animated {
109111
blur;
110112

111113
});
114+
_backgroundView.userInteractionEnabled = NO;
112115

113116
[self initSubViewsInContentView];
114117
}
@@ -129,10 +132,10 @@ - (void)setActive:(BOOL)visible animated:(BOOL)animated {
129132

130133
- (void)initSubViewsInContentView {
131134

132-
UILabel *lblHotKey = [[UILabel alloc] initWithFrame:CGRectMake(12.0f, 5.0f, kScreen_Width, 30.0f)];
135+
UILabel *lblHotKey = [[UILabel alloc] initWithFrame:CGRectMake(12.0f, 5.0f, kScreen_Width, 33.0f)];
133136
[lblHotKey setUserInteractionEnabled:YES];
134137
[lblHotKey setText:@"热门话题"];
135-
[lblHotKey setFont:[UIFont systemFontOfSize:14.0f]];
138+
[lblHotKey setFont:[UIFont systemFontOfSize:12.0f]];
136139
[lblHotKey setTextColor:[UIColor colorWithHexString:@"0x999999"]];
137140
[_contentView addSubview:lblHotKey];
138141

@@ -141,13 +144,29 @@ - (void)initSubViewsInContentView {
141144

142145
UIImageView *moreIconView = [[UIImageView alloc] initWithFrame:CGRectMake(kScreen_Width - 31.0f, 10.0f, 20.0f, 20.0f)];
143146
moreIconView.image = [UIImage imageNamed:@"me_info_arrow_left"];
147+
moreIconView.centerY = lblHotKey.centerY;
144148
[_contentView addSubview:moreIconView];
145149

146-
_topicHotkeyView = [[TopicHotkeyView alloc] init];
147-
_topicHotkeyView.delegate = self;
150+
__weak typeof(self) weakSelf = self;
151+
152+
_topicHotkeyView = [[TopicHotkeyView alloc] initWithFrame:CGRectMake(0, 40, kScreen_Width, 0)];
153+
_topicHotkeyView.block = ^(NSDictionary *dict){
154+
[weakSelf.searchBar resignFirstResponder];
155+
156+
CSTopicDetailVC *vc = [[CSTopicDetailVC alloc] init];
157+
vc.topicID = [dict[@"id"] intValue];
158+
[weakSelf.parentVC.navigationController pushViewController:vc animated:YES];
159+
160+
//TODO psy
161+
// self.searchBar.text = key;
162+
// [CSSearchModel addSearchHistory:self.searchBar.text];
163+
// [self initSearchHistoryView];
164+
// [self.searchBar resignFirstResponder];
165+
//
166+
// [self initSearchResultsTableView];
167+
};
148168
[_contentView addSubview:_topicHotkeyView];
149169
[_topicHotkeyView mas_makeConstraints:^(MASConstraintMaker *make) {
150-
151170
make.left.mas_equalTo(@0);
152171
make.top.mas_equalTo(@40);
153172
make.width.mas_equalTo(kScreen_Width);
@@ -156,18 +175,19 @@ - (void)initSubViewsInContentView {
156175

157176
[self initSearchHistoryView];
158177

159-
__weak typeof(self) weakSelf = self;
160178
[[Coding_NetAPIManager sharedManager] request_TopicHotkeyWithBlock:^(id data, NSError *error) {
161179
if(data) {
162180
NSArray *array = data;
163181
NSMutableArray *hotkeyArray = [[NSMutableArray alloc] initWithCapacity:6];
164-
for (int i = 0; i < (array.count >= 6 ? 6 : array.count); i++) {
165-
[hotkeyArray addObject:[(NSDictionary *)array[i] objectForKey:@"name"]];
182+
for (int i = 0; i < array.count; i++) {
183+
if (i == 6) {
184+
break;
185+
}
186+
[hotkeyArray addObject:array[i]];
166187
}
167188

168189
[weakSelf.topicHotkeyView setHotkeys:hotkeyArray];
169-
[weakSelf.topicHotkeyView mas_remakeConstraints:^(MASConstraintMaker *make) {
170-
190+
[weakSelf.topicHotkeyView mas_updateConstraints:^(MASConstraintMaker *make) {
171191
make.left.mas_equalTo(@0);
172192
make.top.mas_equalTo(@40);
173193
make.width.mas_equalTo(kScreen_Width);
@@ -292,14 +312,15 @@ - (void)initSearchHistoryView {
292312
}
293313

294314
- (void)didClickedMoreHotkey:(UIGestureRecognizer *)sender {
295-
315+
[self.searchBar resignFirstResponder];
316+
296317
RKSwipeBetweenViewControllers *nav_topic = [RKSwipeBetweenViewControllers newSwipeBetweenViewControllers];
297318
[nav_topic.viewControllerArray addObjectsFromArray:@[[CSHotTopicVC new],[CSMyTopicVC new]]];
298319
nav_topic.buttonText = @[@"热门话题", @"我的话题"];
299320

300321
CATransition *transition = [CATransition animation];
301-
transition.duration = 0.3;
302-
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
322+
transition.duration = 0.5;
323+
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
303324
transition.type = kCATransitionPush;
304325
transition.subtype = kCATransitionFromRight;
305326

@@ -335,15 +356,6 @@ - (void)didClickedHistory:(UIGestureRecognizer *)sender {
335356
[self initSearchResultsTableView];
336357
}
337358

338-
- (void)didClickHotkey:(NSString *)key {
339-
self.searchBar.text = key;
340-
[CSSearchModel addSearchHistory:self.searchBar.text];
341-
[self initSearchHistoryView];
342-
[self.searchBar resignFirstResponder];
343-
344-
[self initSearchResultsTableView];
345-
}
346-
347359
#pragma mark -
348360
#pragma mark Search Data Request
349361

Coding_iOS/Controllers/Topic/CSHotTopicVC.m

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#import "UILabel+Common.h"
1616
#import "Tweet.h"
1717

18-
#import "CSTopic.h"
1918
#import "CSTopicDetailVC.h"
2019

2120

@@ -28,12 +27,16 @@ @interface CSHotTopicVC ()<UITableViewDataSource,UITableViewDelegate>
2827
@property (nonatomic,strong)CSScrollview *adView;
2928
@end
3029

31-
@implementation CSHotTopicVC
30+
@implementation CSHotTopicVC{
31+
CGFloat _adHeight;
32+
}
3233

3334
- (void)viewDidLoad {
3435
[super viewDidLoad];
3536
self.view.backgroundColor = [UIColor whiteColor];
3637

38+
_adHeight = kScreen_Width * 214 / 640;
39+
3740
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"返回"
3841
style:UIBarButtonItemStylePlain
3942
target:self
@@ -135,15 +138,16 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
135138
}
136139

137140
CSTopicDetailVC *vc = [[CSTopicDetailVC alloc] init];
138-
vc.topic = _topiclist[indexPath.row - 1];
141+
NSDictionary *topic = _topiclist[indexPath.row - 1];
142+
vc.topicID = [topic[@"id"] intValue];
139143
[self.navigationController pushViewController:vc animated:YES];
140144
}
141145

142146
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
143147
if (_adlist.count == 0) {
144148
return 0;
145149
}
146-
return 80;
150+
return _adHeight;
147151
}
148152

149153
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
@@ -152,15 +156,21 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
152156
}
153157

154158
if (!_adView) {
159+
155160
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
156161
layout.minimumLineSpacing = 0;
157-
layout.itemSize = CGSizeMake(kScreen_Width, 80);
162+
layout.itemSize = CGSizeMake(kScreen_Width, _adHeight);
158163
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
159-
_adView = [[CSScrollview alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 80) layout:layout];
164+
165+
_adView = [[CSScrollview alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, _adHeight) layout:layout];
160166
_adView.autoScrollEnable = YES;
161167
_adView.showPageControl = NO;
168+
169+
__weak CSHotTopicVC *wself = self;
162170
_adView.tapBlk = ^(CSScrollItem* item) {
163-
NSLog(@"tap --\n%@",item.data);
171+
CSTopicDetailVC *vc = [[CSTopicDetailVC alloc] init];
172+
vc.topicID = [item.data[@"id"] intValue];
173+
[wself.navigationController pushViewController:vc animated:YES];
164174
};
165175
}
166176

Coding_iOS/Controllers/Topic/CSMyTopicVC.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
#import "CSMyTopicVC.h"
10-
#import "CSTopic.h"
1110

1211
#import "Login.h"
1312

@@ -119,7 +118,7 @@ - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel
119118

120119
- (void)goToTopic:(NSDictionary*)topic{
121120
CSTopicDetailVC *vc = [[CSTopicDetailVC alloc] init];
122-
vc.topic = topic;
121+
vc.topicID = [topic[@"id"] intValue];
123122
[self.navigationController pushViewController:vc animated:YES];
124123
}
125124

Coding_iOS/Controllers/Topic/CSScrollview.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,10 @@ - (void)setRefIteml:(CSScrollItem*)refIteml
177177
{
178178
if (!_imgView) {
179179
_imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
180+
_imgView.backgroundColor = kColorTableBG;
180181
[self.contentView addSubview:_imgView];
181182
}
182-
183-
[_imgView sd_setImageWithURL:[NSURL URLWithString:refIteml.imgUrl] placeholderImage:[UIImage imageNamed:@"gif_mark"]];
184-
//TODO psy 可有placeholder?
183+
[_imgView sd_setImageWithURL:[NSURL URLWithString:refIteml.imgUrl]];
185184
}
186185

187186
@end

Coding_iOS/Controllers/Topic/CSTopicCreateVC.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#import "CSTopicModel.h"
1111
#import "Coding_NetAPIManager.h"
1212

13-
#import "CSTopic.h"
1413

1514
#define kCellIdentifier_TopicNameCell @"kCellIdentifier_TopicNameCell"
1615

@@ -152,6 +151,10 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege
152151
if (tableView == _mySearchDisplayController.searchResultsTableView) {
153152
return 0;
154153
}
154+
155+
if (section == 0 && _historyTopiclist.count == 0) {
156+
return 0;
157+
}
155158
return 20;
156159
}
157160

@@ -162,6 +165,11 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
162165
return nil;
163166
}
164167

168+
if (section == 0 && _historyTopiclist.count == 0) {
169+
return nil;
170+
}
171+
172+
165173
UIView *headerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, height)];
166174
headerV.backgroundColor = kColorTableSectionBg;
167175

Coding_iOS/Controllers/Topic/CSTopicDetailVC.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010

1111

1212
@interface CSTopicDetailVC : UIViewController
13-
@property (nonatomic,strong)NSDictionary *topic;
13+
//@property (nonatomic,strong)NSDictionary *topic;
14+
@property (nonatomic,assign)int topicID;
1415
@end

Coding_iOS/Controllers/Topic/CSTopicDetailVC.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#import "TweetSendViewController.h"
1111
#import "Coding_NetAPIManager.h"
1212
#import "CSTopicHeaderView.h"
13-
#import "CSTopic.h"
1413

1514
#import "TweetCell.h"
1615
#import "Tweet.h"
@@ -21,6 +20,7 @@ @interface CSTopicDetailVC ()<UITableViewDataSource,UITableViewDelegate>
2120

2221
@property (nonatomic,strong)Tweets *curTweets;
2322

23+
@property (nonatomic,strong)CSTopicHeaderView *tableHeader;
2424
@end
2525

2626
@implementation CSTopicDetailVC
@@ -42,7 +42,7 @@ - (void)sendRequest{
4242
// }
4343
__weak typeof(self) weakSelf = self;
4444

45-
[[Coding_NetAPIManager sharedManager] request_PublicTweetsWithTopic:[self.topic[@"id"] intValue] andBlock:^(id data, NSError *error) {
45+
[[Coding_NetAPIManager sharedManager] request_PublicTweetsWithTopic:_topicID andBlock:^(id data, NSError *error) {
4646
[weakSelf.curTweets configWithTweets:data];
4747
[weakSelf.myTableView reloadData];
4848
// [weakSelf.view endLoading];
@@ -59,6 +59,15 @@ - (void)sendRequest{
5959
}];
6060
}
6161

62+
- (void)refreshheader {
63+
[[Coding_NetAPIManager sharedManager]request_TopicDetailsWithTopicID:_topicID block:^(id data, NSError *error) {
64+
if (data) {
65+
[self.tableHeader updateWithTopic:data];
66+
}
67+
68+
}];
69+
}
70+
6271
#pragma mark - table view
6372

6473
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
@@ -93,8 +102,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
93102
- (void) setupUI {
94103
self.navigationItem.title = @"话题";
95104

96-
// [self.parentViewController.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"tweetBtn_Nav"] style:UIBarButtonItemStylePlain target:self action:@selector(sendTweet)] animated:NO];
97-
98105
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"tweetBtn_Nav"] style:UIBarButtonItemStylePlain target:self action:@selector(sendTweet)];
99106

100107
_myTableView = ({
@@ -108,11 +115,12 @@ - (void) setupUI {
108115

109116
CSTopicHeaderView *header = [[CSTopicHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 191)];
110117
header.parentVC = self;
111-
[header updateWithTopic:self.topic];
118+
// [header updateWithTopic:self.topic];
112119
tableView.tableHeaderView = header;
113120
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
114121
make.edges.equalTo(self.view);
115122
}];
123+
_tableHeader = header;
116124
tableView;
117125
});
118126
}

Coding_iOS/Controllers/Topic/CSTopiclistView.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import <UIKit/UIKit.h>
1010
#import "SWTableViewCell.h"
11-
#import "CSTopic.h"
1211

1312
typedef void(^TopicListViewBlock)(NSDictionary* topic);
1413
typedef enum {

0 commit comments

Comments
 (0)