在短视频app源码开发中,仿抖音短视频热门页面的实现只不过是多了一个由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

这样仿抖音样式的短视频热门页面就大体实现了,之后还会继续分享关于短视频app源码开发的相关知识。

短视频app源码开发:仿抖音短视频热门页面的实现相关推荐

  1. 一对一交友源码,仿抖音短视频源码,搭建的秘密你了解多少?

    一对一交友源码,仿抖音短视频源码,搭建的秘密你了解多少? 5G技术马上到来,现在直播遇到的一些问题,比如延迟.卡顿.掉线等,很有可能这些情况就不复存在了.而且,其他的一些高科技产品会运用到直播过程中, ...

  2. 短视频app源码开发,音视频合成的实现

    在短视频app源码开发中,音视频数据的处理是关键,尤其是音视频合成处理,只有有声音的短视频内容才更有吸引力,在短视频app源码中如何实现音视频的合成呢? 音频合成 调用方法 //音视频合成func a ...

  3. 短视频app源码开发,音视频混合的实现

    在短视频app源码开发中,音视频的混合是对音视频数据进行处理时,非常重要的一个环节,只有做好了音视频混合,才能录制更好的短视频内容. //音视频合成 func videoAudioMerge() {/ ...

  4. 如何开发仿抖音短视频APP源码?

    如何开发仿抖音短视频APP源码? 流程列表 开发一个短视频最主要的流程分为 3 个,下面我将分步教你实现这 3 个流程下的各个功能点,功能点 API 可按需调用: 视频拍摄 a.启动拍摄 b.给拍摄添 ...

  5. 仿抖音短视频APP源码如何开发抖音类似特效

    仿抖音短视频APP源码如何开发抖音类似特效 1.特效概览 特效列表 特效列表 2.『灵魂出窍』 抖音的实现效果如下: 灵魂出窍 我的实现效果如下: ezgif.com-rotate.gif 代码实现 ...

  6. 短视频app源码开发,短视频平台框架搭建

    科技发展,技术进步,音视频异军突起.无视频,不网络,短视频成为最重要的信息载体之一,是互联网核心组成部分.构建高效的短视频app源码,是慎之又慎的问题.从架构的角度,探讨短视频app源码的构建与技术选 ...

  7. 小视频app源码开发不可忽视的重点在这里

    小视频app适合各种移动场景下的用户参与,以内容为卖点,通过大数据功能筛选市场喜爱的视频,实际操作简单,容易引发二次传播,且变现模式成熟,因此,在抖音.微信等小视频app的刺激下,小视频app源码开发 ...

  8. 抖你妹原版主题源码,仿抖音模式套图SEO源码

    靓图库模板抖你妹原版主题源码,仿抖音模式套图SEO源码,wordpress图片主题不送数据!此源码为wordpress模板,需先安装wordpress后才能使用! 注意:PHP版本越高越好,PHP必须 ...

  9. 用成品短视频App源码开发您的下一个创意项目

    您是否曾经有过一个创意项目,但是不知道如何实现?成品短视频App源码可以帮助您快速开发出一个小视频App.本文将介绍如何使用成品短视频App源码来开发您的下一个创意项目. 什么是成品短视频App源码? ...

最新文章

  1. 数据预处理之独热编码(One-Hot Encoding)
  2. JS获取系统时间--JavaScript基础
  3. jvm类加载过程_JVM知识点——深入理解JVM的类加载
  4. R语言绘制空间热力图
  5. 论面向组合子程序设计方法 之 重构2
  6. no Bloomberg, wind, ceic, csmar at cambridge
  7. PHP的php://
  8. wxpython菜单栏嵌套窗口_如何在wxpython中使嵌套的Panel和Sizer工作
  9. 阿里云杨敬宇:四层技术构建基于城市场景的边缘计算
  10. java 主线程等待_Java实现主线程等待子线程
  11. Xcode7.0.1:升级Xcode7上传AppStore失败问题
  12. 2017上海ACM ECL-final 总结
  13. jquery_EasyUI使用细节注意
  14. openldap备份与还原
  15. 满满干货!邮储银行java面试
  16. Pycharm 搭建 Django 项目 (非常详细)
  17. 智慧校园云端管理系统的设计和实现(附源码及数据库)
  18. 【阿卡乐谱】【日常分享】超级强大的简谱-《茉莉花》
  19. 2021第十二届蓝桥杯国赛B组题解(C/C++)
  20. JZOJ100047. 【NOIP2017提高A组模拟7.14】基因变异

热门文章

  1. STM32开发基于SPI接口的OLED数据显示
  2. 风控报表体系建设与风控指标
  3. 1700+X370+1088超频数据
  4. 社区新零售另一个风口:社区拼团震撼来袭
  5. Excel制作斜线表头的制作
  6. java 字符串模糊搜索_Java中的模糊字符串搜索库
  7. Chocolat.js – 响应式的 jQuery Lightbox 插件
  8. 【生活指南】如何网上办理新农保养老年审? 异地养老年审 - 微信社保年审
  9. 数据压缩实验六 MPEG音频压缩编码
  10. 数学建模 # 论文撰写技巧