Skip to content

Commit 0c5d3ae

Browse files
committed
修复网络请求的bug
修复网络请求的bug
1 parent f805abe commit 0c5d3ae

16 files changed

Lines changed: 62 additions & 41 deletions

File tree

Binary file not shown.

TTNews/Classes/Me/Controller/MeTableViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ -(void)viewWillAppear:(BOOL)animated {
4949
-(void)viewWillDisappear:(BOOL)animated {
5050
[super viewWillDisappear:animated];
5151
[[NSNotificationCenter defaultCenter] removeObserver:self];
52+
[SVProgressHUD dismiss];
5253
}
5354

5455
#pragma mark 更新皮肤模式 接到模式切换的通知后会调用此方法

TTNews/Classes/News/Controller/ContentTableViewController.h

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

99
#import <UIKit/UIKit.h>
10-
#import "TTNormalNews.h"
10+
@class TTNormalNews;
1111

1212
@interface ContentTableViewController : UITableViewController
1313

TTNews/Classes/News/Controller/DetailViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
@interface DetailViewController : UIViewController
1212

1313
@property (nonatomic, copy) NSString *url;
14+
1415
@end

TTNews/Classes/News/Controller/NewsViewController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
#import "NewsViewController.h"
1010
#import <POP.h>
1111
#import <SVProgressHUD.h>
12+
#import <SDImageCache.h>
1213
#import "ContentTableViewController.h"
1314
#import "ChannelCollectionViewCell.h"
1415
#import "TTJudgeNetworking.h"
1516
#import "TTConst.h"
1617
#import "TTTopChannelContianerView.h"
1718
#import "ChannelsSectionHeaderView.h"
19+
#import "TTNormalNews.h"
1820

1921
@interface NewsViewController()<UIScrollViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate, ChannelCollectionViewCellDelegate,TTTopChannelContianerViewDelegate>
2022

@@ -42,6 +44,7 @@ -(void)viewDidLoad {
4244
[self setupChildController];
4345
[self setupContentScrollView];
4446
[self setupCollectionView];
47+
4548
}
4649

4750
-(void)viewWillAppear:(BOOL)animated {
@@ -53,6 +56,7 @@ -(void)viewWillAppear:(BOOL)animated {
5356
-(void)viewWillDisappear:(BOOL)animated {
5457
[super viewWillDisappear:animated];
5558
[[NSNotificationCenter defaultCenter] removeObserver:self];
59+
[[SDImageCache sharedImageCache] clearDisk];
5660
}
5761

5862
#pragma mark --private Method--初始化子控制器
@@ -111,7 +115,7 @@ - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
111115
ContentTableViewController *vc = self.childViewControllers[index];
112116
vc.view.frame = CGRectMake(scrollView.contentOffset.x, 0, self.contentScrollView.frame.size.width, self.contentScrollView.frame.size.height);
113117
vc.tableView.contentInset = UIEdgeInsetsMake(CGRectGetMaxY(self.navigationController.navigationBar.frame)+self.topContianerView.scrollView.frame.size.height, 0, self.tabBarController.tabBar.frame.size.height, 0);
114-
[scrollView addSubview:vc.view];
118+
[scrollView addSubview:vc.view];
115119
}
116120
}
117121

TTNews/Classes/News/Controller/ShowMultiPictureViewController.h

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

99
#import <UIKit/UIKit.h>
10+
1011
@interface ShowMultiPictureViewController : UIViewController
1112

1213
@property (nonatomic, strong) NSArray *imageUrls;

TTNews/Classes/News/Model/TTNormalNews.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ -(void)setImageurls:(NSArray *)imageurls {
4040

4141

4242
}
43+
4344
@end

TTNews/Classes/News/View/ChannelCollectionViewCell.xib

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,14 @@
1313
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
1414
<rect key="frame" x="0.0" y="0.0" width="140" height="60"/>
1515
<subviews>
16-
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="specialcell_nav_btn" translatesAutoresizingMaskIntoConstraints="NO" id="Au8-YS-QRd">
17-
<rect key="frame" x="30" y="15" width="80" height="30"/>
18-
<constraints>
19-
<constraint firstAttribute="width" constant="80" id="0D5-Jc-qOd"/>
20-
<constraint firstAttribute="width" constant="60" id="FJx-Qy-7Ra"/>
21-
<constraint firstAttribute="height" constant="30" id="i5T-jq-wfl"/>
22-
<constraint firstAttribute="height" constant="30" id="uVt-uk-bqF"/>
23-
</constraints>
24-
<variation key="default">
25-
<mask key="constraints">
26-
<exclude reference="FJx-Qy-7Ra"/>
27-
<exclude reference="uVt-uk-bqF"/>
28-
</mask>
29-
</variation>
30-
</imageView>
3116
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MXO-7x-8PR">
32-
<rect key="frame" x="52" y="22" width="35.5" height="17"/>
33-
<fontDescription key="fontDescription" type="system" pointSize="14"/>
17+
<rect key="frame" x="53.5" y="22" width="33" height="16"/>
18+
<fontDescription key="fontDescription" type="system" pointSize="13"/>
3419
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
3520
<nil key="highlightedColor"/>
3621
</label>
3722
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="A8x-3E-gkH">
38-
<rect key="frame" x="27" y="12" width="15" height="15"/>
23+
<rect key="frame" x="2" y="2" width="15" height="15"/>
3924
<constraints>
4025
<constraint firstAttribute="height" constant="15" id="RmQ-Ue-rSB"/>
4126
<constraint firstAttribute="width" constant="15" id="T8M-K3-JHR"/>
@@ -45,17 +30,44 @@
4530
<action selector="DeleteTheChannel:" destination="gTV-IL-0wX" eventType="touchUpInside" id="t0q-Hv-s36"/>
4631
</connections>
4732
</button>
33+
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="specialcell_nav_btn" translatesAutoresizingMaskIntoConstraints="NO" id="Au8-YS-QRd">
34+
<rect key="frame" x="5" y="5" width="130" height="50"/>
35+
<constraints>
36+
<constraint firstAttribute="width" constant="80" id="0D5-Jc-qOd"/>
37+
<constraint firstAttribute="width" constant="60" id="FJx-Qy-7Ra"/>
38+
<constraint firstAttribute="height" constant="30" id="i5T-jq-wfl"/>
39+
<constraint firstAttribute="height" constant="30" id="uVt-uk-bqF"/>
40+
</constraints>
41+
<variation key="default">
42+
<mask key="constraints">
43+
<exclude reference="0D5-Jc-qOd"/>
44+
<exclude reference="FJx-Qy-7Ra"/>
45+
<exclude reference="i5T-jq-wfl"/>
46+
<exclude reference="uVt-uk-bqF"/>
47+
</mask>
48+
</variation>
49+
</imageView>
4850
</subviews>
4951
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
5052
</view>
5153
<constraints>
5254
<constraint firstItem="MXO-7x-8PR" firstAttribute="centerY" secondItem="gTV-IL-0wX" secondAttribute="centerY" id="21v-LM-x71"/>
55+
<constraint firstItem="Au8-YS-QRd" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="5" id="Fby-OY-f1D"/>
5356
<constraint firstItem="Au8-YS-QRd" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="FhS-sb-HDs"/>
57+
<constraint firstAttribute="trailing" secondItem="Au8-YS-QRd" secondAttribute="trailing" constant="5" id="NwP-UB-GgJ"/>
58+
<constraint firstItem="Au8-YS-QRd" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="5" id="Rqf-dN-3hr"/>
5459
<constraint firstItem="MXO-7x-8PR" firstAttribute="centerX" secondItem="gTV-IL-0wX" secondAttribute="centerX" id="YkY-ir-qnT"/>
60+
<constraint firstAttribute="bottom" secondItem="Au8-YS-QRd" secondAttribute="bottom" constant="5" id="pZn-2R-h1M"/>
5561
<constraint firstItem="A8x-3E-gkH" firstAttribute="top" secondItem="Au8-YS-QRd" secondAttribute="top" constant="-3" id="u4f-an-Q5r"/>
5662
<constraint firstItem="Au8-YS-QRd" firstAttribute="centerY" secondItem="gTV-IL-0wX" secondAttribute="centerY" id="uN7-C6-Vw6"/>
5763
<constraint firstItem="A8x-3E-gkH" firstAttribute="leading" secondItem="Au8-YS-QRd" secondAttribute="leading" constant="-3" id="ygb-fI-JcG"/>
5864
</constraints>
65+
<variation key="default">
66+
<mask key="constraints">
67+
<exclude reference="FhS-sb-HDs"/>
68+
<exclude reference="uN7-C6-Vw6"/>
69+
</mask>
70+
</variation>
5971
<connections>
6072
<outlet property="channelNameLabel" destination="MXO-7x-8PR" id="vcT-wb-706"/>
6173
<outlet property="deleteButton" destination="A8x-3E-gkH" id="Qgf-ak-PJK"/>

TTNews/Classes/News/View/TTTopChannelContianerView.m

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010

1111
@interface TTTopChannelContianerView()
1212

13-
@property (nonatomic, weak) UIButton *currentSelectedChannelButton;
13+
@property (nonatomic, weak) UIButton *lastSelectedButton;
1414
@property (nonatomic, weak) UIView *indicatorView;
1515

1616
@end
1717

18-
static CGFloat kTitleLabelNorimalFont = 15;
19-
static CGFloat kTitleLabelSelectedFont = 18;
18+
static CGFloat kTitleLabelNorimalFont = 13;
19+
static CGFloat kTitleLabelSelectedFont = 16;
2020
static CGFloat kAddChannelWidth = 30;
2121
static CGFloat kSliderViewWidth = 20;
22+
static CGFloat buttonWidth = 65;
2223

2324
@implementation TTTopChannelContianerView
2425

@@ -33,7 +34,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
3334
#pragma mark channelNameArray的setter方法,channelNameArray
3435
- (void)setChannelNameArray:(NSArray *)channelNameArray {
3536
_channelNameArray = channelNameArray;
36-
CGFloat buttonWidth = self.scrollView.frame.size.width/5;
37+
// CGFloat buttonWidth = self.scrollView.frame.size.width/5;
3738
self.scrollView.contentSize = CGSizeMake(buttonWidth * channelNameArray.count, 0);
3839
for (NSInteger i = 0; i < channelNameArray.count; i++) {
3940
UIButton *button = [self createChannelButton];
@@ -120,10 +121,10 @@ - (UIButton *)createChannelButton{
120121

121122
#pragma mark 选择了某个ChannelButton
122123
- (void)clickChannelButton:(UIButton *)sender {
123-
self.currentSelectedChannelButton.titleLabel.font = [UIFont systemFontOfSize:kTitleLabelNorimalFont];
124-
self.currentSelectedChannelButton.enabled = YES;
125-
self.currentSelectedChannelButton = sender;
126-
self.currentSelectedChannelButton.enabled = NO;
124+
self.lastSelectedButton.titleLabel.font = [UIFont systemFontOfSize:kTitleLabelNorimalFont];
125+
self.lastSelectedButton.enabled = YES;
126+
self.lastSelectedButton = sender;
127+
self.lastSelectedButton.enabled = NO;
127128
CGFloat newOffsetX = sender.center.x - [UIScreen mainScreen].bounds.size.width*0.5;
128129
if (newOffsetX < 0) {
129130
newOffsetX = 0;
@@ -178,7 +179,7 @@ - (void)clickAddButton:(UIButton *)button{
178179

179180
#pragma mark 添加新闻频道:增加scrollView的contensize,然后在最后添加一个channelButton
180181
- (void)addAChannelButtonWithChannelName:(NSString *)channelName {
181-
CGFloat buttonWidth = self.scrollView.frame.size.width/5;
182+
// CGFloat buttonWidth = self.scrollView.frame.size.width/5;
182183
UIButton *button = [self createChannelButton];
183184
self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width + buttonWidth, 0);
184185
button.frame = CGRectMake(self.scrollView.contentSize.width - buttonWidth , 0, buttonWidth, self.frame.size.height);

0 commit comments

Comments
 (0)