Commit f8678cc15b644872abc77cd75f4f47ca41960347
1 parent
ddcd8641
转移UICollectionview
Showing
2 changed files
with
63 additions
and
77 deletions
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLiveListController.m
| ... | ... | @@ -9,8 +9,14 @@ |
| 9 | 9 | #import "LVCUGCLiveListController.h" |
| 10 | 10 | #import "LiveLIstService.h" |
| 11 | 11 | #import "LVCUGCLiveListModel.h" |
| 12 | +#import "LVCUGCLivePlayerCell.h" | |
| 13 | +#import "LVCUGCLivePlayerModel.h" | |
| 12 | 14 | |
| 13 | -@interface LVCUGCLiveListController () | |
| 15 | +static NSString *cellId = @"cellId"; | |
| 16 | + | |
| 17 | +@interface LVCUGCLiveListController ()<UICollectionViewDelegate, UICollectionViewDataSource> | |
| 18 | + | |
| 19 | +@property (nonatomic, strong) UICollectionView *collectionView; | |
| 14 | 20 | |
| 15 | 21 | @end |
| 16 | 22 | |
| ... | ... | @@ -40,6 +46,60 @@ |
| 40 | 46 | |
| 41 | 47 | } |
| 42 | 48 | |
| 49 | +#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 50 | +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { | |
| 51 | + | |
| 52 | + return 1; | |
| 53 | +} | |
| 54 | + | |
| 55 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { | |
| 56 | + | |
| 57 | + return 6; | |
| 58 | +} | |
| 59 | + | |
| 60 | +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { | |
| 61 | + | |
| 62 | + LVCUGCLivePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; | |
| 63 | + | |
| 64 | + NSLog(@"cell ------> %@",cell); | |
| 65 | + | |
| 66 | + LVCUGCLivePlayerModel *model = [[LVCUGCLivePlayerModel alloc] init]; | |
| 67 | + cell.model = model; | |
| 68 | + | |
| 69 | + return cell; | |
| 70 | +} | |
| 71 | + | |
| 72 | +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
| 73 | + | |
| 74 | + | |
| 75 | +} | |
| 76 | + | |
| 77 | +- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { | |
| 78 | + | |
| 79 | + NSLog(@"停止"); | |
| 80 | +} | |
| 81 | + | |
| 82 | +#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 83 | +- (UICollectionView *)collectionView { | |
| 84 | + | |
| 85 | + if (!_collectionView) { | |
| 86 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 87 | + layout.minimumLineSpacing = 0; | |
| 88 | + layout.minimumInteritemSpacing = 0; | |
| 89 | + layout.itemSize = self.view.bounds.size; | |
| 90 | + _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout]; | |
| 91 | + _collectionView.pagingEnabled = YES; | |
| 92 | + _collectionView.contentOffset = CGPointMake(0, 30); | |
| 93 | + _collectionView.showsHorizontalScrollIndicator = NO; | |
| 94 | + _collectionView.scrollEnabled = NO; | |
| 95 | + _collectionView.dataSource = self; | |
| 96 | + _collectionView.delegate = self; | |
| 97 | + [_collectionView registerClass:[LVCUGCLivePlayerCell class] forCellWithReuseIdentifier:cellId]; | |
| 98 | + } | |
| 99 | + return _collectionView; | |
| 100 | +} | |
| 101 | + | |
| 102 | + | |
| 43 | 103 | - (void)didReceiveMemoryWarning { |
| 44 | 104 | [super didReceiveMemoryWarning]; |
| 45 | 105 | // Dispose of any resources that can be recreated. | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLivePlayerController.m
| ... | ... | @@ -10,17 +10,9 @@ |
| 10 | 10 | #import <CNLivePlayerSDK/CNLiveWebcastManager.h> |
| 11 | 11 | #import "LVCUGCPlayerLoadingView.h" |
| 12 | 12 | #import "LVCUGCBackgroundView.h" |
| 13 | -#import "LVCUGCLivePlayerCell.h" | |
| 14 | -#import "LVCUGCLivePlayerModel.h" | |
| 15 | 13 | |
| 16 | -static NSString *cellId = @"cellId"; | |
| 17 | 14 | |
| 18 | -@interface LVCUGCLivePlayerController ()<UICollectionViewDelegate, UICollectionViewDataSource> { | |
| 19 | - | |
| 20 | - int _count; | |
| 21 | -} | |
| 22 | - | |
| 23 | -@property (nonatomic, strong) UICollectionView *collectionView; | |
| 15 | +@interface LVCUGCLivePlayerController () | |
| 24 | 16 | |
| 25 | 17 | @property (nonatomic, strong) LVCUGCBackgroundView *bgView; // 背景视图 |
| 26 | 18 | |
| ... | ... | @@ -45,79 +37,13 @@ static NSString *cellId = @"cellId"; |
| 45 | 37 | - (void)viewDidLoad { |
| 46 | 38 | [super viewDidLoad]; |
| 47 | 39 | |
| 48 | - _count = 0; | |
| 49 | - | |
| 50 | 40 | self.view.backgroundColor = [UIColor whiteColor]; |
| 51 | 41 | |
| 52 | - [self.view addSubview:self.bgView]; | |
| 53 | - [self.view addSubview:self.collectionView]; | |
| 54 | - | |
| 55 | -} | |
| 56 | - | |
| 57 | -#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 58 | -- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { | |
| 59 | - | |
| 60 | - return 1; | |
| 61 | -} | |
| 62 | - | |
| 63 | -- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { | |
| 64 | - | |
| 65 | - return 6; | |
| 66 | -} | |
| 67 | - | |
| 68 | -- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { | |
| 69 | - | |
| 70 | - LVCUGCLivePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; | |
| 71 | - | |
| 72 | - NSLog(@"cell ------> %@",cell); | |
| 73 | - | |
| 74 | - LVCUGCLivePlayerModel *model = [[LVCUGCLivePlayerModel alloc] init]; | |
| 75 | - cell.model = model; | |
| 76 | - | |
| 77 | - return cell; | |
| 78 | -} | |
| 79 | - | |
| 80 | -- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
| 81 | - | |
| 82 | - CGFloat offsetY = scrollView.contentOffset.y; | |
| 83 | - | |
| 84 | - if ((offsetY - _count * SCREEN_HEIGHT) > 0) { | |
| 85 | - if ((offsetY - _count * SCREEN_HEIGHT) == SCREEN_HEIGHT) { | |
| 86 | - _count ++; | |
| 87 | - } | |
| 88 | - } else if ((offsetY - _count * SCREEN_HEIGHT) < 0) { | |
| 89 | - if ((offsetY - _count * SCREEN_HEIGHT) == -SCREEN_HEIGHT) { | |
| 90 | - _count --; | |
| 91 | - } | |
| 92 | - } | |
| 93 | - NSLog(@"**********>>>%f =====>>>%d",offsetY,_count); | |
| 94 | -} | |
| 95 | - | |
| 96 | -- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { | |
| 97 | - | |
| 98 | - NSLog(@"停止"); | |
| 42 | + //[self.view addSubview:self.bgView]; | |
| 99 | 43 | } |
| 100 | 44 | |
| 101 | 45 | |
| 102 | 46 | #pragma mark - getMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 103 | -- (UICollectionView *)collectionView { | |
| 104 | - | |
| 105 | - if (!_collectionView) { | |
| 106 | - UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 107 | - layout.minimumLineSpacing = 0; | |
| 108 | - layout.minimumInteritemSpacing = 0; | |
| 109 | - layout.itemSize = self.view.bounds.size; | |
| 110 | - _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout]; | |
| 111 | - _collectionView.pagingEnabled = YES; | |
| 112 | - _collectionView.contentOffset = CGPointMake(0, 30); | |
| 113 | - _collectionView.showsHorizontalScrollIndicator = NO; | |
| 114 | - _collectionView.scrollEnabled = NO; | |
| 115 | - _collectionView.dataSource = self; | |
| 116 | - _collectionView.delegate = self; | |
| 117 | - [_collectionView registerClass:[LVCUGCLivePlayerCell class] forCellWithReuseIdentifier:cellId]; | |
| 118 | - } | |
| 119 | - return _collectionView; | |
| 120 | -} | |
| 121 | 47 | |
| 122 | 48 | - (LVCUGCBackgroundView *)bgView { |
| 123 | 49 | ... | ... |