CNLIVEViewController.m
2.25 KB
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
//
// CNLIVEViewController.m
// CNLiveVideoClassifyKit
//
// Created by 杨苓玉 on 08/05/2021.
// Copyright (c) 2021 杨苓玉. All rights reserved.
//
#import "CNLIVEViewController.h"
#import <CNLiveBaseKit/CNLiveBaseKit.h>
#import "CNliveCollectionViewCell.h"
@interface CNLIVEViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
{
NSArray *segArr;
}
@property (nonatomic, strong)UICollectionView *collectionView;
@end
@implementation CNLIVEViewController
- (void)viewDidLoad
{
[super viewDidLoad];
segArr = @[@"分类"];
[self.view addSubview:self.collectionView];
}
#pragma mrk - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return segArr.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CNliveCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseCell" forIndexPath:indexPath];
cell.titleName = segArr[indexPath.row];
return cell;
}
#pragma mark - UICollectionViewDelegate
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:
{
}
break;
default:
break;
}
}
#pragma mark - Getting
-(UICollectionView *)collectionView
{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(100, 40);
layout.minimumLineSpacing = 10;
layout.minimumInteritemSpacing = 10;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight) collectionViewLayout:layout];
[_collectionView registerClass:[CNliveCollectionViewCell class] forCellWithReuseIdentifier:@"reuseCell"];
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor whiteColor];
_collectionView.dataSource = self;
}
return _collectionView;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end