Skip to content

Commit 6e86bee

Browse files
committed
check fix
1 parent be65db5 commit 6e86bee

4 files changed

Lines changed: 67 additions & 51 deletions

File tree

Coding_iOS/Controllers/Shop/ExchangeGoodsViewController.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
#import "ExchangeGoodsViewController.h"
77

8-
#import "ResetLabelViewController.h"
98
#import "TPKeyboardAvoidingTableView.h"
109
#import "Coding_NetAPIManager.h"
11-
#import "ProjectTag.h"
1210
#import "MBProgressHUD+Add.h"
1311
#import "ShopOrderTextFieldCell.h"
1412
#import "ShopGoodsInfoView.h"
@@ -293,5 +291,11 @@ - (void)exchangeActionRquest:(NSString *)pwd
293291
}];
294292
}
295293

294+
- (void)dealloc
295+
{
296+
_myTableView.dataSource = nil;
297+
_myTableView.delegate = nil;
298+
}
299+
296300
@end
297301

Coding_iOS/Controllers/Shop/ShopOrderViewController.m

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
@interface ShopOrderViewController ()<iCarouselDataSource,iCarouselDelegate>
1818
@property (nonatomic, strong) ShopOrderModel *myOrder;
19-
//@property (nonatomic , copy) ProjectActivityBlock block;
2019
@property (strong, nonatomic) XTSegmentControl *mySegmentControl;
2120
@property (strong, nonatomic) NSArray *titlesArray;
2221
@property (strong, nonatomic) iCarousel *myCarousel;
@@ -37,6 +36,26 @@ - (void)viewDidLoad
3736
_myOrder = [[ShopOrderModel alloc] init];
3837
_myOrder.orderType = ShopOrderAll;
3938

39+
[self setUpView];
40+
[self loadData];
41+
}
42+
43+
- (void)loadData
44+
{
45+
__weak typeof(self) weakSelf = self;
46+
[self.view beginLoading];
47+
[[Coding_NetAPIManager sharedManager] request_shop_OrderListWithOrder:_myOrder andBlock:^(id data, NSError *error) {
48+
[weakSelf.view endLoading];
49+
if (data) {
50+
ShopOrderListView *listView = (ShopOrderListView *)[weakSelf.myCarousel itemViewAtIndex:weakSelf.myOrder.orderType];
51+
[listView reloadData];
52+
}
53+
}];
54+
}
55+
56+
57+
- (void)setUpView
58+
{
4059
//添加myCarousel
4160
self.myCarousel = ({
4261
iCarousel *icarousel = [[iCarousel alloc] initWithFrame:CGRectZero];
@@ -52,42 +71,19 @@ - (void)viewDidLoad
5271
[icarousel mas_makeConstraints:^(MASConstraintMaker *make) {
5372
make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(kMySegmentControl_Height, 0, 0, 0));
5473
}];
55-
74+
5675
icarousel;
5776
});
58-
59-
//添加滑块
60-
__weak typeof(_myCarousel) weakCarousel = _myCarousel;
61-
77+
__weak typeof(self) weakSelf = self;
6278
self.mySegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height) Items:self.titlesArray selectedBlock:^(NSInteger index) {
63-
[weakCarousel scrollToItemAtIndex:index animated:NO];
64-
65-
ShopOrderListView *listView = (ShopOrderListView *)[_myCarousel itemViewAtIndex:index];
66-
_myOrder.orderType = index;
67-
listView.myOrder = _myOrder;
79+
ShopOrderListView *listView = (ShopOrderListView *)[weakSelf.myCarousel itemViewAtIndex:index];
80+
weakSelf.myOrder.orderType = index;
81+
listView.myOrder = weakSelf.myOrder;
6882
[listView reloadData];
69-
7083
}];
7184
[self.view addSubview:self.mySegmentControl];
72-
73-
[self loadData];
7485
}
7586

76-
- (void)loadData
77-
{
78-
__weak typeof(self) weakSelf = self;
79-
[self.view beginLoading];
80-
[[Coding_NetAPIManager sharedManager] request_shop_OrderListWithOrder:_myOrder andBlock:^(id data, NSError *error) {
81-
[weakSelf.view endLoading];
82-
if (data) {
83-
84-
ShopOrderListView *listView = (ShopOrderListView *)[weakSelf.myCarousel itemViewAtIndex:_myOrder.orderType];
85-
[listView reloadData];
86-
}
87-
}];
88-
}
89-
90-
9187
#pragma mark - Getter/Setter
9288
- (NSArray*)titlesArray
9389
{
@@ -130,6 +126,13 @@ - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel{
130126
}];
131127
}
132128

129+
- (void)dealloc
130+
{
131+
_myCarousel.dataSource = nil;
132+
_myCarousel.delegate = nil;
133+
_mySegmentControl = nil;
134+
}
135+
133136
@end
134137

135138

Coding_iOS/Controllers/Shop/ShopViewController.m

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ @interface ShopViewController ()<UICollectionViewDataSource,UICollectionViewDele
3333
}
3434

3535
@property(nonatomic,strong)XTSegmentControl *shopSegmentControl;
36+
@property(nonatomic,strong)UICollectionView *collectionView;
3637
@property(nonatomic,strong)Shop *shopObject;
38+
3739
@end
3840

3941
@implementation ShopViewController
@@ -63,7 +65,6 @@ - (void)bannerClicked:(NSString *)linkStr{
6365
}
6466

6567

66-
6768
#pragma mark-
6869
#pragma mark---------------------- ControllerLife ---------------------------
6970

@@ -94,7 +95,6 @@ - (void)viewDidAppear:(BOOL)animated
9495
_isRequest = YES;
9596
[self requestgiftsList];
9697
}
97-
9898
}
9999

100100
#pragma mark-
@@ -112,14 +112,15 @@ - (void)refreshMore{
112112
- (void)requestgiftsList {
113113

114114
[self.view beginLoading];
115+
__weak typeof(self) weakSelf = self;
115116
[[Coding_NetAPIManager sharedManager] request_shop_bannersWithBlock:^(id data, NSError *error) {
116-
_shopObject.shopBannerArray = data;
117-
[_collectionView reloadData];
117+
weakSelf.shopObject.shopBannerArray = data;
118+
[weakSelf.collectionView reloadData];
118119
}];
119120

120121
[[Coding_NetAPIManager sharedManager] request_shop_userPointWithShop:_shopObject andBlock:^(id data, NSError *error) {
121122
if (data) {
122-
[ self loadGiftsList];
123+
[weakSelf loadGiftsList];
123124
}
124125
}];
125126
}
@@ -130,7 +131,7 @@ - (void)loadGiftsList
130131
[[Coding_NetAPIManager sharedManager] request_shop_giftsWithShop:_shopObject andBlock:^(id data, NSError *error) {
131132
[weakSelf.view endLoading];
132133
if (data) {
133-
[_collectionView reloadData];
134+
[weakSelf.collectionView reloadData];
134135
}else
135136
[NSObject showHudTipStr:@"Error"];
136137
}];
@@ -170,24 +171,27 @@ - (void)setUpSegmentControl
170171
{
171172
//添加滑块
172173
NSArray *_segmentItems = @[@"全部商品",@"可兑换商品"];
173-
//__weak typeof(_shopSegmentControl) weakCarousel = _shopSegmentControl;
174+
__weak typeof(self) weakSelf = self;
174175
_shopSegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(_collectionHeaderView.frame)- kMySegmentControl_Height - 5, kScreen_Width, kMySegmentControl_Height) Items:_segmentItems selectedBlock:^(NSInteger index) {
175-
if (index == _oldSelectedIndex) {
176-
return;
177-
}
178-
_oldSelectedIndex = index;
179-
_shopObject.shopType = index;
180-
[_collectionView reloadData];
181-
if (_collectionView.contentOffset.y > CGRectGetHeight(_collectionHeaderView.frame) ) {
182-
[_collectionView setContentOffset:CGPointMake(0, CGRectGetHeight(_collectionHeaderView.frame)) animated:NO];
183-
}
184-
176+
[weakSelf segmentControlSelecteIndex:index];
185177
}];
186178
_shopSegmentControl.backgroundColor = [UIColor whiteColor];
187179
[_collectionHeaderView addSubview:_shopSegmentControl];
188180
[self.view bringSubviewToFront:_shopSegmentControl];
189181
}
190182

183+
- (void)segmentControlSelecteIndex:(NSInteger)index
184+
{
185+
if (index == _oldSelectedIndex) {
186+
return;
187+
}
188+
_oldSelectedIndex = index;
189+
_shopObject.shopType = index;
190+
[_collectionView reloadData];
191+
if (_collectionView.contentOffset.y > CGRectGetHeight(_collectionHeaderView.frame) ) {
192+
[_collectionView setContentOffset:CGPointMake(0, CGRectGetHeight(_collectionHeaderView.frame)) animated:NO];
193+
}
194+
}
191195

192196

193197
#pragma mark - UICollectionViewDataSource
@@ -226,7 +230,6 @@ - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UIColl
226230
height = kMySegmentControl_Height + bannerHeight ;
227231
_collectionHeaderView.frame = CGRectMake(0, 0, kScreen_Width, height);
228232
}
229-
230233
return UIEdgeInsetsMake(5 + height, 10, 10, 10);
231234
}
232235

Coding_iOS/Views/TableListView/ShopOrderListView.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ - (instancetype)initWithFrame:(CGRect)frame withOder:(ShopOrderModel *)order
5050

5151
_myRefreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView];
5252
[_myRefreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
53-
54-
5553
}
5654
return self;
5755
}
@@ -145,6 +143,14 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
145143

146144
}
147145

146+
- (void)dealloc
147+
{
148+
_currentOrderCell = nil;
149+
_myRefreshControl = nil;
150+
_myTableView.dataSource = nil;
151+
_myTableView.delegate = nil;
152+
}
153+
148154
@end
149155

150156

0 commit comments

Comments
 (0)