1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// OnlineLearningViewController.m
// Lighting
//
// Created by 曹云霄 on 2016/11/16.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "OnlineLearningViewController.h"
#import "OnlineLearningTableViewCell.h"
#import "OnlineLearningDetailViewController.h"
@interface OnlineLearningViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
/**
学习类别
*/
@property (nonatomic,strong) NSMutableArray *studyTypeArray;
@end
@implementation OnlineLearningViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpCollectionView];
[self getLearningModuleData];
}
#pragma mark - UICollectionView
- (void)setUpCollectionView
{
self.onlineLearningFlowLayout.itemSize = CGSizeMake((ScreenWidth-60)/3.0, ((ScreenWidth-60)/3.0)*0.9);
self.onlineLearningFlowLayout.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20);
self.onlineLearningFlowLayout.minimumLineSpacing = 10;
self.onlineLearningFlowLayout.minimumInteritemSpacing = 10;
}
#pragma mark - 学习模块数据
- (void)getLearningModuleData
{
WS(weakSelf);
[XBLoadingView showHUDViewWithDefault];;
[HTTP networkWithDictionaryRequestWithURL:SERVERREQUESTURL(STUDYTYPES) withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
[XBLoadingView hideHUDViewWithDefault];
if (RESULT(returnValue)) {
StudyTypeResponse *response = [[StudyTypeResponse alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
[weakSelf.studyTypeArray addObjectsFromArray:response.types];
}else {
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
[weakSelf.onlineLearningCollectionView reloadData];
}withFailureBlock:^(NSError *error) {
[XBLoadingView hideHUDViewWithDefault];
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark - <UICollectionViewDelegate,UICollectionViewDataSource>
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.studyTypeArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
OnlineLearningTableViewCell *learningCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"OnlineLearningTableViewCell" forIndexPath:indexPath];
learningCell.studeType = self.studyTypeArray[indexPath.row];
return learningCell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
OnlineLearningDetailViewController *studyDetail = [[[self class] getLearningCenterStoryboardClass]instantiateViewControllerWithIdentifier:@"OnlineLearningDetailViewController"];
studyDetail.studyTypeEntity = self.studyTypeArray[indexPath.row];
[self.navigationController pushViewController:studyDetail animated:YES];
}
#pragma mark - lazy
- (NSMutableArray *)studyTypeArray
{
if (!_studyTypeArray) {
_studyTypeArray = [NSMutableArray array];
}
return _studyTypeArray;
}
@end