短视频APP源码中系统评论功能是如何实现的

简介: 短视频系统中评论功能的分量在短视频功能里可谓是举足轻重,下面简单介绍下,短视频系统中的评论功能的实现方式:评论分为对视频的评论和对评论的回复两部分:对于评论列表大家再熟悉不过了,就是一个tableview罢了,相信刚入门的技术也可以实现。

短视频系统中评论功能的分量在短视频功能里可谓是举足轻重,下面简单介绍下,短视频系统中的评论功能的实现方式:
评论分为对视频的评论和对评论的回复两部分:
对于评论列表大家再熟悉不过了,就是一个tableview罢了,相信刚入门的技术也可以实现。技术的关键在于对评论的回复,我们使用了tableview的嵌套,即:在评论的cell中创建回复的tablview,使用代理功能来实现对数据和UI界面的精准控制,下面是实现的具体方式:

_contentL.attributedText = attstr;
    if ([_model.replys intValue] > 0) {
        CGFloat HHHH = 0.0;
        for (NSDictionary *dic in _replyArray) {
            detailmodel *model = [[detailmodel alloc]initWithDic:dic];
            HHHH += model.rowH;
        }
        if ([_model.replys intValue] == 1) {
            _tableHeight.constant = HHHH;
            _replyTable.tableFooterView = nil;
        }else{
//            if (!_replyBottomView) {
                NSLog(@"===%d",page);
                _model.replayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 20)];
                _model.replayView.backgroundColor = CellRow_Cor;
                //回复
                UIButton * replyBtn = [UIButton buttonWithType:0];
                replyBtn.backgroundColor = [UIColor clearColor];
                replyBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
                replyBtn.titleLabel.font = [UIFont systemFontOfSize:12];
                [replyBtn addTarget:self action:@selector(makeReply:) forControlEvents:UIControlEventTouchUpInside];
                BOOL showNum = NO;
                if (_model.replyList.count==1) {
                    showNum = YES;
                }
                [self changeMoreShowText:showNum andBtn:replyBtn];
                NSMutableAttributedString *attstr2 = [[NSMutableAttributedString alloc]initWithString:@"收起"];
                [attstr2 addAttribute:NSForegroundColorAttributeName value:RGB_COLOR(@"#969696", 1) range:NSMakeRange(0, 2)];
                NSTextAttachment *attach2 = [[NSTextAttachment alloc] init];
                UIImage *image2 = [UIImage imageNamed:@"relpay_三角上.png"];
                NSAttributedString *imageString2;
                if (image2) {
                    attach2.image = image2;
                    attach2.bounds = CGRectMake(0, -4, 15, 15);
                    imageString2 =   [NSAttributedString attributedStringWithAttachment:attach2];
                    [attstr2 appendAttributedString:imageString2];
                }
                [replyBtn setAttributedTitle:attstr2 forState:UIControlStateSelected];
                [_model.replayView addSubview:replyBtn];
                //记录按钮属性
                _model.replyMoreBtn = replyBtn;
                [replyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.bottom.equalTo(_model.replayView);
                    make.left.equalTo(_model.replayView).offset(26);
                }];       
                if ((_model.replyList.count % 10 != 0
                     && _model.replyList.count % 10 != 1
                     && _model.replyList.count% 10 != 3)
                     || ((_model.replyList.count+1)== [_model.replys intValue])
                    ) {
                    replyBtn.selected = YES;
                }else{
                    replyBtn.selected = NO;
                }
            _replyTable.tableFooterView = _model.replayView;
            _tableHeight.constant = HHHH+20;
        }
    }else{
        _tableHeight.constant = 0;
        _replyTable.tableFooterView = nil;
    }
- (void)makeReply:(UIButton *)replyBtn{
    if (replyBtn.selected) {
        NSDictionary *dic = [_replyArray firstObject];
        [_replyArray removeAllObjects];
        [_replyArray addObject:[dic mutableCopy]];
        _model.replyList = [_replyArray mutableCopy];
//        [_replyTable reloadData];
        replyBtn.selected = NO;
        [self changeMoreShowText:YES andBtn:replyBtn];
        [self.delegate reloadCurCell:_model andIndex:_curIndex andReplist:_replyArray needRefresh:YES];
    }else{     
        if (_replyArray.count == 1) {
            page = 1;
        }else{
            page ++;
        }
        [self requestData:NO andBtn:replyBtn];
    }
}
-(void)changeMoreShowText:(BOOL)isFirstPage andBtn:(UIButton *)replyBtn{
    NSString *tempStr;
    if (isFirstPage) {
        tempStr  = [NSString stringWithFormat:@"展开%d条回复",[_model.replys intValue]>=2?([_model.replys intValue]-1):(1)];
    }else{
        tempStr  = [NSString stringWithFormat:@"展开更多回复"];
    }
    NSMutableAttributedString *attstr = [[NSMutableAttributedString alloc]initWithString:tempStr];
    [attstr addAttribute:NSForegroundColorAttributeName value:RGB_COLOR(@"#969696", 1) range:NSMakeRange(0, tempStr.length)];
    NSTextAttachment *attach = [[NSTextAttachment alloc] init];
    UIImage *image = [UIImage imageNamed:@"relpay_三角下.png"];
    NSAttributedString *imageString;
    if (image) {
        attach.image = image;
        attach.bounds = CGRectMake(0, -4, 15, 15);
        imageString =   [NSAttributedString attributedStringWithAttachment:attach];
        [attstr appendAttributedString:imageString];
    }
    [replyBtn setAttributedTitle:attstr forState:0];
}

看了上述短视频APP源码评论功能的方法介绍,大家是不是眼前一亮?是不是豁然开朗?关于更多短视频系统功能的介绍可以关注我们的账号,我们会持续更新关于短视频功能介绍。

目录
相关文章
|
5月前
|
小程序 视频直播 数据安全/隐私保护
如何在1v1视频直播交友APP中实现防录屏防截屏功能?
婚恋交友市场快速增长,1v1社交应用海外投放增86.49%,中东、东南亚及北美需求旺盛。用户偏好私密高效交流,国内“云相亲”兴起。开发需合规备案、实名认证,并防范诈骗。本文详解原生APP防录屏技术:Android通过MediaProjection检测,iOS监听UIScreen状态,结合动态水印、远程销毁等增强防护,平衡体验与安全。
|
5月前
|
JavaScript API 开发工具
如何在原生App中调用Uniapp的原生功能?
如何在原生App中调用Uniapp的原生功能?
828 139
|
6月前
|
移动开发 小程序 Android开发
基于 uni-app 开发的废品回收类多端应用功能与界面说明
本文将对一款基于 uni-app 开发的废品回收类多端应用,从多端支持范围、核心功能模块及部分界面展示进行客观说明,相关资源信息也将一并呈现。
221 0
|
6月前
|
存储 前端开发 API
可配置化App启动弹窗系统:实现后台动态管理与热更新引导-蜻蜓Q系统laravel+vue3-优雅草卓伊凡
可配置化App启动弹窗系统:实现后台动态管理与热更新引导-蜻蜓Q系统laravel+vue3-优雅草卓伊凡
410 5
可配置化App启动弹窗系统:实现后台动态管理与热更新引导-蜻蜓Q系统laravel+vue3-优雅草卓伊凡
|
5月前
|
存储 自然语言处理 算法
参照Yalla、Hawa等主流APP核心功能,开发一款受欢迎的海外语聊需要从哪些方面入手
海外语聊APP开发需结合Yalla、Hawa等主流产品,聚焦多语言支持、实时音视频、社交互动与安全合规。兼顾技术架构、本地化运营与法律风险,避免劣质成品代码,平衡创新与成本,打造差异化出海产品。(239字)
|
6月前
|
存储 前端开发 安全
实现“永久登录”:针对蜻蜓Q系统的用户体验优化方案(前端uni-app+后端Laravel详解)-优雅草卓伊凡
实现“永久登录”:针对蜻蜓Q系统的用户体验优化方案(前端uni-app+后端Laravel详解)-优雅草卓伊凡
289 5
|
7月前
|
缓存 小程序 iOS开发
基于uni-app+vue3手机桌面oadmin管理系统
基于uniapp+vue3+pinia2+uv-ui仿ios手机界面oa后台系统解决方案。支持运行到h5+小程序+app端。
373 5
|
6月前
|
存储 小程序 Java
热门小程序源码合集:微信抖音小程序源码支持PHP/Java/uni-app完整项目实践指南
小程序已成为企业获客与开发者创业的重要载体。本文详解PHP、Java、uni-app三大技术栈在电商、工具、服务类小程序中的源码应用,提供从开发到部署的全流程指南,并分享选型避坑与商业化落地策略,助力开发者高效构建稳定可扩展项目。
|
7月前
|
安全 测试技术 虚拟化
Omnissa App Volumes 4, version 2506 - 实时应用程序交付系统
Omnissa App Volumes 4, version 2506 - 实时应用程序交付系统
144 0
|
程序员 开发工具 开发者
短视频APP开发者告诉你:苹果手机加上它也能用美颜
如果苹果手机加入了它,微信也能自带美颜,那么,“它”是什么呢?

热门文章

最新文章