短影片程式,仿抖音短影片熱門頁面開發
熱門頁面
上 篇 文我們介紹了短影片程式推薦頁面的開發,這篇文說一下短影片程式的熱門頁面。熱門頁面只不過是多了一個由UICollectionView 呈現多個影片圖片的中間介面,點開後播放影片介面其實就是推薦介面,所以這裡並沒有什麼核心難點,只是簡單介紹下這個 collectionView 就好了。
#import "HotVideoVC.h"
#import <MJRefresh/MJRefresh.h>
#import "RecommendVideoVC.h"
#import "NearbyVideoModel.h"
#import "VideoCollectionCell.h"
#import "AFNetworking.h"
@interface HotVideoVC ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property(nonatomic,strong)NSMutableArray *allArray;
@property(nonatomic,strong)NSArray *modelrray;
@property(nonatomic,strong)UICollectionView *collectionView;
@end
@implementation HotVideoVC
{
NSInteger _page;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO;
_modelrray = [NSArray array];
_page = 1;
self.navigationController.interactivePopGestureRecognizer.delegate = (id) self;
self.automaticallyAdjustsScrollViewInsets = NO;
self.allArray = [NSMutableArray array];
UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc]init];
flow.scrollDirection = UICollectionViewScrollDirectionVertical;
flow.itemSize = CGSizeMake(_window_width/2-1, (_window_width/2-1) * 1.4);
flow.minimumLineSpacing = 2;
flow.minimumInteritemSpacing = 2;
self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,statusbarHeight, _window_width, _window_height-49-statusbarHeight-ShowDiff) collectionViewLayout:flow];
[self.collectionView registerNib:[UINib nibWithNibName:@"VideoCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"VideoCollectionCell"];
self.collectionView.delegate =self;
self.collectionView.dataSource = self;
self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
_page ++;
[self pullInternetforNew:_page];
}];
self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
_page = 1;
[self pullInternetforNew:_page];
}];
[self.view addSubview:self.collectionView];
self.view.backgroundColor = Black_Cor;
self.collectionView.backgroundColor = [UIColor blackColor];
[self pullInternetforNew:1];
// 因為列表不可以每次 都重新重新整理,影響使用者體驗,也浪費流量
// 在影片頁面輸出影片後返回
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getLiveList:) name:@"delete" object:nil];
// 釋出影片成功之後返回首頁重新整理列表
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pullInternetforNewDown) name:@"reloadlist" object:nil];
}
// 在影片頁面刪除影片回來後刪除
-(void)getLiveList:(NSNotification *)nsnitofition{
NSString *videoid = [NSString stringWithFormat:@"%@",[[nsnitofition userInfo] valueForKey:@"videoid"]];
NSDictionary *deletedic = [NSDictionary dictionary];
for (NSDictionary *subdic in self.allArray) {
NSString *videoids = [NSString stringWithFormat:@"%@",[subdic valueForKey:@"id"]];
if ([videoid isEqual:videoids]) {
deletedic = subdic;
break;
}
}
if (deletedic) {
[self.allArray removeObject:deletedic];
[self.collectionView reloadData];
}
}
-(void)refreshNear{
}
//down
-(void)pullInternetforNewDown{
self.allArray = [NSMutableArray array];
_page = 1;
[self pullInternetforNew:_page];
}
-(void)getDataByFooterup{
_page ++;
[self pullInternetforNew:_page];
}
-(void)pullInternetforNew:(NSInteger)pages{
self.collectionView.userInteractionEnabled = NO;
NSString *url = [NSString stringWithFormat:@"%@&p=%ld",_url,(long)pages];
WeakSelf;
[YBNetworking postWithUrl:url Dic:nil Suc:^(NSDictionary *data, NSString *code, NSString *msg) {
[weakSelf.collectionView.mj_header endRefreshing];
[weakSelf.collectionView.mj_footer endRefreshing];
weakSelf.collectionView.userInteractionEnabled = YES;
if ([code isEqual:@"0"]) {
NSArray *info = [data valueForKey:@"info"];
if (_page == 1) {
[self.allArray removeAllObjects];
}
[self.allArray addObjectsFromArray:info];
// 載入成功 停止重新整理
[self.collectionView.mj_header endRefreshing];
[self.collectionView.mj_footer endRefreshing];
[self.collectionView reloadData];
if (self.allArray.count > 0) {
[PublicView hiddenTextNoData:_collectionView];
}else{
[PublicView showTextNoData:_collectionView text1:@"" text2:@" 暫無熱門影片哦 ~"];
}
if (info.count <= 0) {
[self.collectionView.mj_footer endRefreshingWithNoMoreData];
}
}else if ([code isEqual:@"700"]){
[PublicObj tokenExpired:minstr([data valueForKey:@"msg"])];
}else{
if (self.allArray) {
[self.allArray removeAllObjects];
}
[self.collectionView reloadData];
[PublicView showTextNoData:_collectionView text1:@"" text2:@" 暫無熱門影片哦 ~"];
}
} Fail:^(id fail) {
weakSelf.collectionView.userInteractionEnabled = YES;
self.collectionView.userInteractionEnabled = YES;
if (self.allArray) {
[self.allArray removeAllObjects];
}
[self.collectionView reloadData];
[PublicView showTextNoData:_collectionView text1:@"" text2:@" 暫無熱門影片哦 ~"];
[self.collectionView.mj_header endRefreshing];
[self.collectionView.mj_footer endRefreshing];
}];
}
#pragma mark - Table view data source
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.allArray.count;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
return 2;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
VideoCollectionCell *cell = (VideoCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath];
RecommendVideoVC *video = [[RecommendVideoVC alloc]init];
video.fromWhere = @"myVideoV";
video.curentIndex = indexPath.row;
video.videoList = _allArray;
video.pages = _page;
video.firstPlaceImage = cell.bgImageV.image;
video.requestUrl = _url;
video.block = ^(NSMutableArray *array, NSInteger page,NSInteger index) {
_page = page;
self.allArray = array;
[self.collectionView reloadData];
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:NO];
};
// video.hidesBottomBarWhenPushed = YES;
[[TCBaseAppDelegate sharedAppDelegate] pushViewController:video animated:YES];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
VideoCollectionCell *cell = (VideoCollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"VideoCollectionCell" forIndexPath:indexPath];
NSDictionary *subdic = _allArray[indexPath.row];
cell.isList = @"1";
cell.model = [[NearbyVideoModel alloc] initWithDic:subdic];
return cell;
}
@end
至此抖音樣式的短影片程式已經大體實現了。
宣告:本文由雲豹科技轉發自
a z q
部落格,如有侵權請聯絡作者刪除
原文連結:https://blog.csdn.net/weixin_42433480/article/details/90295434
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69982461/viewspace-2779977/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 短影片程式原始碼,如何實現短影片的熱門頁面原始碼
- 短影片直播APP成品開發直播系統仿抖音APP無加密APP加密
- 短影片app開發的付費熱門是什麼,短影片依舊內容為王APP
- 短影片平臺開發,首先要搭建短影片框架框架
- 抖音短影片開發,SDK包含的功能及技術實現方式
- android短影片開發,uniapp頁面捲軸到指定位置AndroidAPP
- 短影片app開發,短影片系統發展的收益方式是什麼?APP
- 短影片
- 抖音新劍法:PC端成短影片新戰場?
- 免費抖音短影片地址無水印解析api介面API
- 短影片直播功能開發定製短影片系統功能需求無加密加密
- 奇樂短影片開發技術丨奇樂直播短影片系統程式設計開發詳情程式設計
- 凹音短影片軟體開發(類似現成)
- 短影片自媒體怎麼入門?入門短影片的秘籍看這
- 短影片社交平臺開發,短影片直播帶貨,成品原始碼二次開發原始碼
- 短影片直播APP原生開發直播系統無加密搭建定製短影片APP加密
- 移動短影片直播開發,短影片原始碼搭建社交平臺原生APP原始碼APP
- EffectCreator,一款必備的抖音短影片編輯工具
- 抖音短影片動態封面設定教程 抖音動態封面怎麼設定?
- 抖音seo怎麼做的?抖音短影片seo關鍵詞排名技術分享
- 奇樂短影片開發系統丨奇樂社交短影片技術開發案例丨DAPPAPP
- 騰訊上面影視類短影片用哪個軟體採集,短影片搬運如何上熱門?
- TOKTOK短影片系統DAPP開發丨去中心化短影片丨技術分析APP中心化
- flutter3-dylive仿抖音App例項|Flutter3+Getx實戰短影片直播應用FlutterAPP
- 短影片同城引流拓客工具,開闊短影片拓客新思路
- 短影片搜尋都是負面怎麼辦?最佳化正面短影片吧!
- 5個在家也能做的抖音短影片號!快行動起來
- 開發短影片APP需要什麼功能APP
- 短影片應該怎麼製作?短影片運營
- 短影片寶貝=慢?阿里巴巴工程師這樣秒開短影片。阿里工程師
- 短影片app原始碼,Flutter元件--搜尋頁面佈局APP原始碼Flutter元件
- 短影片程式原始碼,怎麼進行短影片稽核機制的架構原始碼架構
- 抖音本地生活服務系統是如何助力商家短影片團購?
- EffectCreator for mac(抖音短影片編輯軟體) v6.4.0啟用版Mac
- 小影片app開發後,短影片軟體搭建部署教程APP
- 如何運營短影片?短影片運營五大技巧!
- 短影片批次釋出軟體,一鍵釋出短影片
- 自媒體短影片如何創作,怎麼快速上熱門