Skip to content

Commit f6ee0a1

Browse files
LambdaLambda
authored andcommitted
bugfix
1 parent 162a038 commit f6ee0a1

File tree

9 files changed

+157
-32
lines changed

9 files changed

+157
-32
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@
506506
8B3516551B6CF69E0049BC45 /* icon_search_clock@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8B3516541B6CF69E0049BC45 /* icon_search_clock@2x.png */; };
507507
8B888E421B72618200806CEE /* CSHotTopicPagesVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B888E411B72618200806CEE /* CSHotTopicPagesVC.m */; };
508508
8BDF9AA61B7456060093BF2C /* HotTopicBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BDF9AA51B7456060093BF2C /* HotTopicBannerView.m */; };
509+
8BDF9AB51B7474990093BF2C /* keyboard_topic@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8BDF9AB01B7474990093BF2C /* keyboard_topic@2x.png */; };
510+
8BDF9AB61B7474990093BF2C /* keyboard_topic@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8BDF9AB11B7474990093BF2C /* keyboard_topic@2x.png */; };
511+
8BDF9AB71B7474990093BF2C /* liziyundong.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 8BDF9AB21B7474990093BF2C /* liziyundong.jpg */; };
512+
8BDF9AB81B7474990093BF2C /* user_info_topic@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8BDF9AB31B7474990093BF2C /* user_info_topic@2x.png */; };
513+
8BDF9AB91B7474990093BF2C /* user_info_topic@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8BDF9AB41B7474990093BF2C /* user_info_topic@2x.png */; };
509514
8E03D4A219F695FE0092F8C8 /* libMobClickLibrary.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E03D49F19F695FE0092F8C8 /* libMobClickLibrary.a */; };
510515
8E03D4A419F696970092F8C8 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E03D4A319F696970092F8C8 /* libz.dylib */; };
511516
8E1C3DEA19E7D58A00EF3032 /* AbstractActionSheetPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E1C3DDA19E7D58A00EF3032 /* AbstractActionSheetPicker.m */; };
@@ -1595,6 +1600,11 @@
15951600
8B888E411B72618200806CEE /* CSHotTopicPagesVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSHotTopicPagesVC.m; sourceTree = "<group>"; };
15961601
8BDF9AA41B7456060093BF2C /* HotTopicBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HotTopicBannerView.h; sourceTree = "<group>"; };
15971602
8BDF9AA51B7456060093BF2C /* HotTopicBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HotTopicBannerView.m; sourceTree = "<group>"; };
1603+
8BDF9AB01B7474990093BF2C /* keyboard_topic@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "keyboard_topic@2x.png"; path = "keyboard/keyboard_topic@2x.png"; sourceTree = "<group>"; };
1604+
8BDF9AB11B7474990093BF2C /* keyboard_topic@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "keyboard_topic@2x.png"; sourceTree = "<group>"; };
1605+
8BDF9AB21B7474990093BF2C /* liziyundong.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = liziyundong.jpg; sourceTree = "<group>"; };
1606+
8BDF9AB31B7474990093BF2C /* user_info_topic@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "user_info_topic@2x.png"; sourceTree = "<group>"; };
1607+
8BDF9AB41B7474990093BF2C /* user_info_topic@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "user_info_topic@2x.png"; path = "userInfo/user_info_topic@2x.png"; sourceTree = "<group>"; };
15981608
8E03D49F19F695FE0092F8C8 /* libMobClickLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libMobClickLibrary.a; sourceTree = "<group>"; };
15991609
8E03D4A019F695FE0092F8C8 /* MobClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MobClick.h; sourceTree = "<group>"; };
16001610
8E03D4A119F695FE0092F8C8 /* MobClickSocialAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MobClickSocialAnalytics.h; sourceTree = "<group>"; };
@@ -3319,7 +3329,6 @@
33193329
8EA6CF1619E240C40076D59C /* AppDelegate.m */,
33203330
4EFE8DB81B3A5727004B7559 /* Launch Screen.xib */,
33213331
8EA6CF1719E240C40076D59C /* Coding_iOS-Info.plist */,
3322-
4EDBECE91B7055BF003E87C3 /* Coding_iOS-Prefix.pch */,
33233332
4E8C51AE1AC0177600B4C51F /* Coding_iOS-Prefix.pch.example */,
33243333
8EA6CF1919E240C40076D59C /* Coding_iOS.xcdatamodeld */,
33253334
8EA6CFC519E240C40076D59C /* Images.xcassets */,
@@ -3480,6 +3489,11 @@
34803489
8EA6CF5D19E240C40076D59C /* Images */ = {
34813490
isa = PBXGroup;
34823491
children = (
3492+
8BDF9AB01B7474990093BF2C /* keyboard_topic@2x.png */,
3493+
8BDF9AB11B7474990093BF2C /* keyboard_topic@2x.png */,
3494+
8BDF9AB21B7474990093BF2C /* liziyundong.jpg */,
3495+
8BDF9AB31B7474990093BF2C /* user_info_topic@2x.png */,
3496+
8BDF9AB41B7474990093BF2C /* user_info_topic@2x.png */,
34833497
4E0022A11B7362EF005308DE /* intro_pages */,
34843498
4E095A751B6B1E40008DC439 /* deadline_calendar */,
34853499
4E095A6A1B69F920008DC439 /* banner */,
@@ -4479,6 +4493,7 @@
44794493
4E6383D41B32665700D98648 /* project_item_member@2x.png in Resources */,
44804494
8EA6D19E19E240C40076D59C /* tipIcon_Tweet@2x.png in Resources */,
44814495
8E97CE9B1A0C7E26006F9AD7 /* coding_emoji_04@2x.png in Resources */,
4496+
8BDF9AB61B7474990093BF2C /* keyboard_topic@2x.png in Resources */,
44824497
8EA6D16D19E240C40076D59C /* nav_tweet_hot@2x.png in Resources */,
44834498
4E6383D81B32665700D98648 /* project_item_topic@2x.png in Resources */,
44844499
4E96E7DC1A1B537E0037C098 /* icon_file_md@2x.png in Resources */,
@@ -4535,6 +4550,7 @@
45354550
4E6383C71B3265DC00D98648 /* mrpr_icon_refaused@2x.png in Resources */,
45364551
8ED2AAFB19F60D5200607A1D /* loading_monkey@2x.png in Resources */,
45374552
8E97CE981A0C7E26006F9AD7 /* coding_emoji_01@2x.png in Resources */,
4553+
8BDF9AB71B7474990093BF2C /* liziyundong.jpg in Resources */,
45384554
8EA6D19519E240C40076D59C /* tipIcon_MergeRequestBean@2x.png in Resources */,
45394555
4E095A7B1B6B1E40008DC439 /* calendar_0x95B763@2x.png in Resources */,
45404556
4E66EE271A28226000DA1B3E /* button_file_denete_enable@2x.png in Resources */,
@@ -4551,6 +4567,8 @@
45514567
4E6383AA1B3262D300D98648 /* taskPriority2@2x.png in Resources */,
45524568
4E66EE281A28226000DA1B3E /* button_file_denete_unable@2x.png in Resources */,
45534569
8E97CE4A1A0A2E11006F9AD7 /* EmojisList.plist in Resources */,
4570+
8BDF9AB51B7474990093BF2C /* keyboard_topic@2x.png in Resources */,
4571+
8BDF9AB81B7474990093BF2C /* user_info_topic@2x.png in Resources */,
45544572
4EBFBD181AA85B8500E4B10E /* add_user_icon@2x.png in Resources */,
45554573
8E97CEA21A0C7E26006F9AD7 /* coding_emoji_11@2x.png in Resources */,
45564574
4E996C061ABBF56A00C704F1 /* n_sex_woman_icon@2x.png in Resources */,
@@ -4627,6 +4645,7 @@
46274645
4EED9DD11B53BBCF000E5827 /* twoFABtn_Nav@2x.png in Resources */,
46284646
4E6383AC1B3262D300D98648 /* taskPriority3@2x.png in Resources */,
46294647
4E53EB5A1AFB090E0034FE1C /* nav_page_unselected@2x.png in Resources */,
4648+
8BDF9AB91B7474990093BF2C /* user_info_topic@2x.png in Resources */,
46304649
);
46314650
runOnlyForDeploymentPostprocessing = 0;
46324651
};

Coding_iOS/Controllers/Topic/CSHotTopicView.m

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
#import "Tweet.h"
1717

1818
#import "CSTopicDetailVC.h"
19-
#import "CodingBannersView.h"
20-
#import "CodingBanner.h"
19+
#import "HotTopicBannerView.h"
2120

2221

2322
#define kCellIdentifier_HotTopicTitleCell @"kCellIdentifier_HotTopicTitleCell"
@@ -26,7 +25,7 @@ @interface CSHotTopicView ()<UITableViewDataSource,UITableViewDelegate>
2625
@property (nonatomic,strong)UITableView *listView;
2726
@property (nonatomic,strong)NSArray *topiclist;
2827
@property (nonatomic,strong)NSMutableArray *adlist;
29-
@property (nonatomic,strong)CodingBannersView *adView;
28+
@property (nonatomic,strong)HotTopicBannerView *adView;
3029
@end
3130

3231
@implementation CSHotTopicView{
@@ -39,7 +38,7 @@ - (id)initWithFrame:(CGRect)frame {
3938

4039
self.backgroundColor = [UIColor whiteColor];
4140

42-
_adHeight = 55 + (kScreen_Width - 2 * kPaddingLeftWidth) * 0.3;
41+
_adHeight = kScreen_Width * 214/640;
4342

4443
_listView = ({
4544
UITableView *tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
@@ -91,32 +90,33 @@ - (void)refreshHotTopiclist{
9190

9291
- (void)refreshAdlist {
9392
__weak typeof(self) wself = self;
94-
_adView = [CodingBannersView new];
93+
_adView = [HotTopicBannerView new];
9594
_adView.backgroundColor = [UIColor whiteColor];
96-
_adView.tapActionBlock = ^(CodingBanner *tapedBanner) {
95+
_adView.tapActionBlock = ^(NSDictionary *tapedBanner) {
9796

9897
CSTopicDetailVC *vc = [[CSTopicDetailVC alloc] init];
99-
vc.topicID = [tapedBanner.id intValue];
98+
vc.topicID = [tapedBanner[@"id"] intValue];
10099
[wself.parentVC.navigationController pushViewController:vc animated:YES];
101100
};
102101

103102
[[Coding_NetAPIManager sharedManager] request_TopicAdlistWithBlock:^(id data, NSError *error) {
104-
if (data && [data isKindOfClass:[NSArray class]]) {
105-
for (NSDictionary *dict in data) {
106-
[wself.adlist addObject:({
107-
CodingBanner *banner = [CodingBanner new];
108-
banner.id = [dict objectForKey:@"id"];
109-
banner.status = @1;
110-
banner.name = [dict objectForKey:@"name"];
111-
banner.title = [dict objectForKey:@"description"];
112-
banner.image = [dict objectForKey:@"image_url"];
113-
banner;
114-
})];
115-
}
116-
}else {
117-
118-
wself.adlist = [NSMutableArray array];
119-
}
103+
// if (data && [data isKindOfClass:[NSArray class]]) {
104+
// for (NSDictionary *dict in data) {
105+
// [wself.adlist addObject:({
106+
// CodingBanner *banner = [CodingBanner new];
107+
// banner.id = [dict objectForKey:@"id"];
108+
// banner.status = @1;
109+
// banner.name = [dict objectForKey:@"name"];
110+
// banner.title = [dict objectForKey:@"description"];
111+
// banner.image = [dict objectForKey:@"image_url"];
112+
// banner;
113+
// })];
114+
// }
115+
// }else {
116+
//
117+
// wself.adlist = [NSMutableArray array];
118+
// }
119+
wself.adlist = data;
120120

121121
wself.adView.frame = CGRectMake(0, 0, kScreen_Width, wself.adlist.count == 0 ? 0 : _adHeight);
122122
wself.adView.curBannerList = wself.adlist;

Coding_iOS/Images/.DS_Store

0 Bytes
Binary file not shown.
1.37 KB
Loading
1.94 KB
Loading

Coding_iOS/Views/HotTopicBannerView.h

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

1111
@interface HotTopicBannerView : UIView
1212
@property (strong, nonatomic) NSArray *curBannerList;
13-
//@property (nonatomic , copy) void (^tapActionBlock)(CodingBanner *tapedBanner);
13+
@property (nonatomic , copy) void (^tapActionBlock)(NSDictionary *bannerData);
1414
- (void)reloadData;
1515
@end

Coding_iOS/Views/HotTopicBannerView.m

Lines changed: 112 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,121 @@
77
//
88

99
#import "HotTopicBannerView.h"
10+
#import "SMPageControl.h"
11+
#import "AutoSlideScrollView.h"
12+
13+
@interface HotTopicBannerView ()
14+
@property (strong, nonatomic) SMPageControl *myPageControl;
15+
@property (strong, nonatomic) AutoSlideScrollView *mySlideView;
16+
@property (strong, nonatomic) NSMutableArray *imageViewList;
17+
@end
1018

1119
@implementation HotTopicBannerView
1220

13-
/*
14-
// Only override drawRect: if you perform custom drawing.
15-
// An empty implementation adversely affects performance during animation.
16-
- (void)drawRect:(CGRect)rect {
17-
// Drawing code
21+
- (instancetype)init
22+
{
23+
24+
self = [super init];
25+
if (self) {
26+
[self setSize:CGSizeMake(kScreen_Width, self.height)];
27+
}
28+
return self;
1829
}
19-
*/
30+
31+
- (void)setCurBannerList:(NSArray *)curBannerList{
32+
_curBannerList = curBannerList;
33+
34+
if (!_myPageControl) {
35+
_myPageControl = ({
36+
SMPageControl *pageControl = [[SMPageControl alloc] init];
37+
pageControl.userInteractionEnabled = NO;
38+
pageControl.backgroundColor = [UIColor clearColor];
39+
pageControl.pageIndicatorImage = [UIImage imageNamed:@"banner__page_unselected"];
40+
pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"banner__page_selected"];
41+
pageControl.frame = CGRectMake(0, 0, kScreen_Width, 0);
42+
pageControl.numberOfPages = _curBannerList.count;
43+
pageControl.currentPage = 0;
44+
pageControl.alignment = SMPageControlAlignmentRight;
45+
pageControl;
46+
});
47+
[self addSubview:_myPageControl];
48+
}
49+
50+
if (!_mySlideView) {
51+
_mySlideView = ({
52+
__weak typeof(self) weakSelf = self;
53+
AutoSlideScrollView *slideView = [[AutoSlideScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, self.height) animationDuration:5.0];
54+
slideView.layer.masksToBounds = YES;
55+
slideView.scrollView.scrollsToTop = NO;
56+
57+
slideView.totalPagesCount = ^NSInteger(){
58+
return weakSelf.curBannerList.count;
59+
};
60+
slideView.fetchContentViewAtIndex = ^UIView *(NSInteger pageIndex){
61+
if (weakSelf.curBannerList.count > pageIndex) {
62+
UIImageView *imageView = [weakSelf p_reuseViewForIndex:pageIndex];
63+
NSDictionary *curBanner = weakSelf.curBannerList[pageIndex];
64+
65+
[imageView sd_setImageWithURL:[curBanner[@"image_url"] urlWithCodePath]];
66+
return imageView;
67+
}else{
68+
return [UIView new];
69+
}
70+
};
71+
slideView.currentPageIndexChangeBlock = ^(NSInteger currentPageIndex){
72+
weakSelf.myPageControl.currentPage = currentPageIndex;
73+
};
74+
slideView.tapActionBlock = ^(NSInteger pageIndex){
75+
if (weakSelf.tapActionBlock && weakSelf.curBannerList.count > pageIndex) {
76+
weakSelf.tapActionBlock(weakSelf.curBannerList[pageIndex]);
77+
}
78+
};
79+
80+
slideView;
81+
});
82+
[self addSubview:_mySlideView];
83+
}
84+
[self reloadData];
85+
NSLog(@"%@", _curBannerList);
86+
}
87+
88+
- (UIImageView *)p_reuseViewForIndex:(NSInteger)pageIndex{
89+
if (!_imageViewList) {
90+
_imageViewList = [[NSMutableArray alloc] initWithCapacity:3];
91+
for (int i = 0; i < 3; i++) {
92+
UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width,self.height)];
93+
view.backgroundColor = [UIColor colorWithHexString:@"0xe5e5e5"];
94+
view.clipsToBounds = YES;
95+
view.contentMode = UIViewContentModeScaleAspectFill;
96+
[_imageViewList addObject:view];
97+
}
98+
}
99+
UIImageView *imageView;
100+
NSInteger currentPageIndex = self.mySlideView.currentPageIndex;
101+
if (pageIndex == currentPageIndex) {
102+
imageView = _imageViewList[1];
103+
}else if (pageIndex == currentPageIndex + 1
104+
|| (labs(pageIndex - currentPageIndex) > 1 && pageIndex < currentPageIndex)){
105+
imageView = _imageViewList[2];
106+
}else{
107+
imageView = _imageViewList[0];
108+
}
109+
return imageView;
110+
}
111+
112+
- (void)reloadData{
113+
self.hidden = _curBannerList.count <= 0;
114+
if (_curBannerList.count <= 0) {
115+
return;
116+
}
117+
118+
NSInteger currentPageIndex = MIN(self.mySlideView.currentPageIndex, _curBannerList.count - 1) ;
119+
120+
_myPageControl.numberOfPages = _curBannerList.count;
121+
_myPageControl.currentPage = currentPageIndex;
122+
123+
[_mySlideView reloadData];
124+
}
125+
20126

21127
@end

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ DEPENDENCIES:
8282
- POP+MCAnimate (= 2.0.1)
8383
- PPiAwesomeButton
8484
- ReactiveCocoa (= 2.3.1)
85-
- TMCache (~> 2.1.0)
8685
- RegexKitLite-NoWarning (= 1.1.0)
8786
- SDCAlertView (= 2.5.2)
8887
- SSKeychain (= 1.2.3)
88+
- TMCache (~> 2.1.0)
8989
- TPKeyboardAvoiding (= 1.2.4)
9090
- TTTAttributedLabel (= 1.10.1)
9191
- UIImage+BlurredFrame (= 0.0.4)

0 commit comments

Comments
 (0)