Commit 3d86069474846300fb19804c6f92ec25815c2247
1 parent
40a8c565
尝试UICollectionview
Showing
7 changed files
with
47 additions
and
39 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
| ... | ... | @@ -204,6 +204,7 @@ |
| 204 | 204 | D2CC7B871E891AA50034B8BF /* LVCUGCLiveListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2CC7B861E891AA50034B8BF /* LVCUGCLiveListController.m */; }; |
| 205 | 205 | D2D236B41E88F8E600B7C517 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */; }; |
| 206 | 206 | D2D236B51E88F8E600B7C517 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B31E88F8E600B7C517 /* CNLiveMsgTools.framework */; }; |
| 207 | + D2D7D18D1E8A581000217771 /* timg.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = D2D7D18C1E8A581000217771 /* timg.jpeg */; }; | |
| 207 | 208 | /* End PBXBuildFile section */ |
| 208 | 209 | |
| 209 | 210 | /* Begin PBXContainerItemProxy section */ |
| ... | ... | @@ -637,6 +638,7 @@ |
| 637 | 638 | D2CC7B861E891AA50034B8BF /* LVCUGCLiveListController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLiveListController.m; sourceTree = "<group>"; }; |
| 638 | 639 | D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; }; |
| 639 | 640 | D2D236B31E88F8E600B7C517 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; }; |
| 641 | + D2D7D18C1E8A581000217771 /* timg.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = timg.jpeg; sourceTree = "<group>"; }; | |
| 640 | 642 | /* End PBXFileReference section */ |
| 641 | 643 | |
| 642 | 644 | /* Begin PBXFrameworksBuildPhase section */ |
| ... | ... | @@ -1558,6 +1560,7 @@ |
| 1558 | 1560 | D25BF88C1E7F7F77007FB138 /* Images */ = { |
| 1559 | 1561 | isa = PBXGroup; |
| 1560 | 1562 | children = ( |
| 1563 | + D2D7D18C1E8A581000217771 /* timg.jpeg */, | |
| 1561 | 1564 | D25BF88F1E7F7F8F007FB138 /* UGCLoading.jpeg */, |
| 1562 | 1565 | D25BF8A41E80EC76007FB138 /* 头像.jpg */, |
| 1563 | 1566 | ); |
| ... | ... | @@ -1843,6 +1846,7 @@ |
| 1843 | 1846 | D2575C801E76A4F300E3A8FC /* resource.bundle in Resources */, |
| 1844 | 1847 | D2029B941E6EAAA50027CD92 /* LaunchScreen.storyboard in Resources */, |
| 1845 | 1848 | D2029B911E6EAAA50027CD92 /* animation.xcassets in Resources */, |
| 1849 | + D2D7D18D1E8A581000217771 /* timg.jpeg in Resources */, | |
| 1846 | 1850 | D2029CB01E6EADE10027CD92 /* MJRefresh.bundle in Resources */, |
| 1847 | 1851 | D2575C7C1E76A4F300E3A8FC /* NHFighterView.nib in Resources */, |
| 1848 | 1852 | D25BF87D1E7B8C78007FB138 /* KSYGPUResource.bundle in Resources */, | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLivePlayerController.m
| ... | ... | @@ -11,10 +11,14 @@ |
| 11 | 11 | #import "LVCUGCPlayerLoadingView.h" |
| 12 | 12 | #import "LVCUGCBackgroundView.h" |
| 13 | 13 | #import "LVCUGCLivePlayerCell.h" |
| 14 | +#import "LVCUGCLivePlayerModel.h" | |
| 14 | 15 | |
| 15 | 16 | static NSString *cellId = @"cellId"; |
| 16 | 17 | |
| 17 | -@interface LVCUGCLivePlayerController ()<UICollectionViewDelegate, UICollectionViewDataSource> | |
| 18 | +@interface LVCUGCLivePlayerController ()<UICollectionViewDelegate, UICollectionViewDataSource> { | |
| 19 | + | |
| 20 | + int _count; | |
| 21 | +} | |
| 18 | 22 | |
| 19 | 23 | @property (nonatomic, strong) UICollectionView *collectionView; |
| 20 | 24 | |
| ... | ... | @@ -41,6 +45,8 @@ static NSString *cellId = @"cellId"; |
| 41 | 45 | - (void)viewDidLoad { |
| 42 | 46 | [super viewDidLoad]; |
| 43 | 47 | |
| 48 | + _count = 0; | |
| 49 | + | |
| 44 | 50 | self.view.backgroundColor = [UIColor whiteColor]; |
| 45 | 51 | |
| 46 | 52 | [self.view addSubview:self.bgView]; |
| ... | ... | @@ -56,19 +62,35 @@ static NSString *cellId = @"cellId"; |
| 56 | 62 | |
| 57 | 63 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { |
| 58 | 64 | |
| 59 | - return 4; | |
| 65 | + return 6; | |
| 60 | 66 | } |
| 61 | 67 | |
| 62 | 68 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { |
| 63 | 69 | |
| 64 | 70 | LVCUGCLivePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; |
| 65 | 71 | |
| 72 | + NSLog(@"cell ------> %@",cell); | |
| 73 | + | |
| 74 | + LVCUGCLivePlayerModel *model = [[LVCUGCLivePlayerModel alloc] init]; | |
| 75 | + cell.model = model; | |
| 76 | + | |
| 66 | 77 | return cell; |
| 67 | 78 | } |
| 68 | 79 | |
| 69 | 80 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { |
| 70 | 81 | |
| 71 | - NSLog(@"一直"); | |
| 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); | |
| 72 | 94 | } |
| 73 | 95 | |
| 74 | 96 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { |
| ... | ... | @@ -87,7 +109,9 @@ static NSString *cellId = @"cellId"; |
| 87 | 109 | layout.itemSize = self.view.bounds.size; |
| 88 | 110 | _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout]; |
| 89 | 111 | _collectionView.pagingEnabled = YES; |
| 112 | + _collectionView.contentOffset = CGPointMake(0, 30); | |
| 90 | 113 | _collectionView.showsHorizontalScrollIndicator = NO; |
| 114 | + _collectionView.scrollEnabled = NO; | |
| 91 | 115 | _collectionView.dataSource = self; |
| 92 | 116 | _collectionView.delegate = self; |
| 93 | 117 | [_collectionView registerClass:[LVCUGCLivePlayerCell class] forCellWithReuseIdentifier:cellId]; |
| ... | ... | @@ -101,6 +125,7 @@ static NSString *cellId = @"cellId"; |
| 101 | 125 | _bgView = [[LVCUGCBackgroundView alloc] initWithFrame:self.view.bounds]; |
| 102 | 126 | _bgView.hidden = YES; |
| 103 | 127 | } |
| 128 | + | |
| 104 | 129 | return _bgView; |
| 105 | 130 | } |
| 106 | 131 | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCLivePlayerCell.h
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCLivePlayerCell.m
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "LVCUGCLivePlayerCell.h" |
| 10 | +#import "UIImage+LVCVagueImage.h" | |
| 10 | 11 | |
| 11 | 12 | @implementation LVCUGCLivePlayerCell |
| 12 | 13 | |
| ... | ... | @@ -31,39 +32,21 @@ |
| 31 | 32 | |
| 32 | 33 | } |
| 33 | 34 | |
| 34 | -#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 35 | -- (LVCUGCPlayerLoadingView *)loadingView { | |
| 35 | +- (void)setPlayer:(CNLiveMoviePlayerController *)player { | |
| 36 | 36 | |
| 37 | - if (!_loadingView) { | |
| 38 | - _loadingView = [[LVCUGCPlayerLoadingView alloc] initWithFrame:self.contentView.bounds bgImageURLStr:@""]; | |
| 37 | + if (_player != player) { | |
| 38 | + _player = player; | |
| 39 | 39 | } |
| 40 | - return _loadingView; | |
| 40 | + | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -- (CNLiveMoviePlayerController *)player { | |
| 43 | +#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 44 | +- (LVCUGCPlayerLoadingView *)loadingView { | |
| 44 | 45 | |
| 45 | - if (!_player) { | |
| 46 | - _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:@"iOStest" | |
| 47 | - authSuccess:^{ | |
| 48 | - | |
| 49 | - _player.videoDecoderMode = CNLiveMovieVideoDecoderMode_AUTO; | |
| 50 | - _player.view.frame = self.contentView.bounds; | |
| 51 | - _player.shouldAutoplay = YES; | |
| 52 | - [_player prepareToPlay]; | |
| 53 | - [self.contentView addSubview:_player.view]; | |
| 54 | - [self.contentView sendSubviewToBack:_player.view]; | |
| 55 | - | |
| 56 | - } authFailed:^(NSDictionary *errorInfo) { | |
| 57 | - NSLog(@"初始化直播播放器失败:%@", errorInfo); | |
| 58 | - | |
| 59 | - | |
| 60 | - } getAnchorStatusResult:^(BOOL result) { | |
| 61 | - | |
| 62 | - NSLog(@"-------------获取主播状态%d", result ? YES : NO); | |
| 63 | - | |
| 64 | - }]; | |
| 46 | + if (!_loadingView) { | |
| 47 | + _loadingView = [[LVCUGCPlayerLoadingView alloc] initWithFrame:self.contentView.bounds]; | |
| 65 | 48 | } |
| 66 | - return _player; | |
| 49 | + return _loadingView; | |
| 67 | 50 | } |
| 68 | 51 | |
| 69 | 52 | #pragma mark - 添加通知监听 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCPlayerLoadingView.h
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCPlayerLoadingView.m
| ... | ... | @@ -9,23 +9,17 @@ |
| 9 | 9 | #import "LVCUGCPlayerLoadingView.h" |
| 10 | 10 | #import "UIImage+LVCVagueImage.h" |
| 11 | 11 | |
| 12 | -@interface LVCUGCPlayerLoadingView() { | |
| 13 | - | |
| 14 | - NSString *_bgImageURLStr; | |
| 15 | -} | |
| 16 | - | |
| 17 | -@property (nonatomic, strong) UIImageView *bgImageView; | |
| 12 | +@interface LVCUGCPlayerLoadingView() | |
| 18 | 13 | |
| 19 | 14 | @end |
| 20 | 15 | |
| 21 | 16 | @implementation LVCUGCPlayerLoadingView |
| 22 | 17 | |
| 23 | -- (instancetype)initWithFrame:(CGRect)frame bgImageURLStr:(NSString *)bgImageURLStr | |
| 18 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 24 | 19 | { |
| 25 | 20 | self = [super initWithFrame:frame]; |
| 26 | 21 | if (self) { |
| 27 | 22 | self.backgroundColor = [UIColor whiteColor]; |
| 28 | - _bgImageURLStr = bgImageURLStr; | |
| 29 | 23 | [self addSubview:self.bgImageView]; |
| 30 | 24 | } |
| 31 | 25 | return self; | ... | ... |
LiveVideoCloud/LiveVideoCloud/Resource/Images/timg.jpeg
0 → 100644
292 KB