Coder Social home page Coder Social logo

dftimelineview's Introduction

DFTimelineView

Version License Platform

仿微信朋友圈 仿微信朋友圈时间轴 支持发送图文 短视频 赞 评论 图片大图浏览 视频预览

Alt    Alt    Alt    Alt    Alt    Alt    Alt    Alt    Alt

Android版

https://github.com/anyunzhong/AndroidTimelineView

Installation

pod 'DFTimelineView'

Usage

#import "DFTimelineView.h"

主时间轴 直接继承 DFTimeLineViewController

添加图文
    DFTextImageLineItem *textImageItem = [[DFTextImageLineItem alloc] init];
    textImageItem.itemId = 10000000; //随便设置一个 待服务器生成
    textImageItem.userId = 10018;
    textImageItem.userAvatar = @"http://file-cdn.datafans.net/avatar/1.jpeg";
    textImageItem.userNick = @"富二代";
    textImageItem.title = @"发表了";
    textImageItem.text = text;
    
    
    NSMutableArray *srcImages = [NSMutableArray array];
    textImageItem.srcImages = srcImages; //大图 可以是本地路径 也可以是网络地址 会自动判断
    
    NSMutableArray *thumbImages = [NSMutableArray array];
    textImageItem.thumbImages = thumbImages; //小图 可以是本地路径 也可以是网络地址 会自动判断
    
    
    for (id img in images) {
        [srcImages addObject:img];
        [thumbImages addObject:img];
    }
    
    textImageItem.location = @"广州信息港";
    [self addItemTop:textImageItem];
    
添加小视频
    DFVideoLineItem *videoItem = [[DFVideoLineItem alloc] init];
    videoItem.itemId = 10000000; //随便设置一个 待服务器生成
    videoItem.userId = 10018;
    videoItem.userAvatar = @"http://file-cdn.datafans.net/avatar/1.jpeg";
    videoItem.userNick = @"富二代";
    videoItem.title = @"发表了";
    videoItem.text = @"新年过节 哈哈"; //这里需要present一个界面 用户填入文字后再发送 场景和发图片一样
    videoItem.location = @"广州";
    
    videoItem.localVideoPath = videoPath;
    videoItem.videoUrl = @""; //网络路径
    videoItem.thumbUrl = @"";
    videoItem.thumbImage = screenShot; //如果thumbImage存在 优先使用thumbImage
    
    [self addItemTop:videoItem];
发送图文后回调
-(void)onSendTextImage:(NSString *)text images:(NSArray *)images;
发送视频后回调
-(void)onSendTextImage:(NSString *)text images:(NSArray *)images;
插入到头部和尾部
//添加到末尾
-(void) addItem:(DFBaseLineItem *) item;

//添加到头部
-(void) addItemTop:(DFBaseLineItem *) item;
赞和评论
    DFLineLikeItem *likeItem1_1 = [[DFLineLikeItem alloc] init];
    likeItem1_1.userId = 10086;
    likeItem1_1.userNick = @"Allen";
    [textImageItem.likes addObject:likeItem1_1];
    
    
    DFLineLikeItem *likeItem1_2 = [[DFLineLikeItem alloc] init];
    likeItem1_2.userId = 10088;
    likeItem1_2.userNick = @"奥巴马";
    [textImageItem.likes addObject:likeItem1_2];
    
    
    
    DFLineCommentItem *commentItem1_1 = [[DFLineCommentItem alloc] init];
    commentItem1_1.commentId = 10001;
    commentItem1_1.userId = 10086;
    commentItem1_1.userNick = @"习大大";
    commentItem1_1.text = @"精彩 大家鼓掌";
    [textImageItem.comments addObject:commentItem1_1];
    
    
    DFLineCommentItem *commentItem1_2 = [[DFLineCommentItem alloc] init];
    commentItem1_2.commentId = 10002;
    commentItem1_2.userId = 10088;
    commentItem1_2.userNick = @"奥巴马";
    commentItem1_2.text = @"欢迎来到美利坚";
    commentItem1_2.replyUserId = 10086;
    commentItem1_2.replyUserNick = @"习大大";
    [textImageItem.comments addObject:commentItem1_2];
    
    
    DFLineCommentItem *commentItem1_3 = [[DFLineCommentItem alloc] init];
    commentItem1_3.commentId = 10003;
    commentItem1_3.userId = 10010;
    commentItem1_3.userNick = @"神雕侠侣";
    commentItem1_3.text = @"呵呵";
    [textImageItem.comments addObject:commentItem1_3];
下拉刷新和上拉更多
-(void) refresh
{
    //下来刷新 从服务器请求最新数据
    //请求完成后结束刷新
    [self endRefresh];
}



-(void) loadMore
{
    //加载更多 从服务器请求数据
    //请求完成后结束上拉更多
    [self endLoadMore];
}
设置封面 用户头像 昵称 签名
    NSString *coverUrl = [NSString stringWithFormat:@"http://file-cdn.datafans.net/temp/12.jpg_%dx%d.jpeg", (int)self.coverWidth, (int)self.coverHeight];
    [self setCover:coverUrl];
    
    NSString *avatarUrl = [NSString stringWithFormat:@"http://file-cdn.datafans.net/avatar/1.jpeg_%dx%d.jpeg", (int)self.userAvatarSize, (int)self.userAvatarSize];
    [self setUserAvatar:avatarUrl];
    
    [self setUserNick:@"Allen"];
    
    [self setUserSign:@"梦想还是要有的 万一实现了呢"];
用户评论和点赞后回调
-(void)onCommentCreate:(long long)commentId text:(NSString *)text itemId:(long long) itemId
{

    DFLineCommentItem *commentItem = [[DFLineCommentItem alloc] init];
    commentItem.commentId = [[NSDate date] timeIntervalSince1970];
    commentItem.userId = 10098;
    commentItem.userNick = @"金三胖";
    commentItem.text = text;
    [self addCommentItem:commentItem itemId:itemId replyCommentId:commentId];
        
    //接下来可以请求服务器操作数据 也可以先请求服务器后再刷新界面
    
}

-(void)onLike:(long long)itemId
{
    //点赞
    DFLineLikeItem *likeItem = [[DFLineLikeItem alloc] init];
    likeItem.userId = 10092;
    likeItem.userNick = @"琅琊榜";
    [self addLikeItem:likeItem itemId:itemId];
    
    //接下来可以请求服务器操作数据 也可以先请求服务器后再刷新界面
    
}
点击头像
-(void)onClickUser:(NSUInteger)userId
{
    //点击左边头像 或者 点击评论和赞的用户昵称
    //例如去到用户单独的时间轴 也可以自定义到其它地方
    UserViewController *controller = [[UserViewController alloc] init];
    [self.navigationController pushViewController:controller animated:YES];
}


-(void)onClickHeaderUserAvatar
{
    [self onClickUser:[当前用户ID]];
}

Extend

STEP1: 扩展新类型 继承 DFBaseLineItem 例如扩展一个分享文章的类型
@interface DFShareLineItem : DFBaseLineItem

@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) UIImage *digest;
...................
@end
STEP2: 扩展CELL 继承 DFBaseLineCell 例如扩展一个分享文章的CELL为例
@implementation DFShareLineCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       //初始化相关View
       
       UILabel *label = ......
       
       [self.bodyView addSubview:label]; 
       //bodyView只中间部分的容器 比如图文就是文字+九宫格图片部分 视频就是文字+视频区域
       //注意:不能把view直接加到cell的contentView上面
    }
    return self;
}


//更新数据 必需实现
-(void)updateWithItem:(DFShareLineItem *)item
{
    [super updateWithItem:item];
    
    //将数据更新到相关view上 同时计算出总的高度
    
    //最后更新父容器的高度
    [self updateBodyView:(计算出的高度)];
    
}

//通过数据计算出cell的高度
-(CGFloat)getCellHeight:(DFShareLineItem *)item
{

    CGFloat height = [super getCellHeight:item]; //父容器公共部分需要的高度

    return height + body部分的高度;
}
STEP3: 将实体和cell关联起来 加载数据的时候 通过实体去找对应的cell

注意: 需要在数据加载之前就注册好

 DFLineCellManager *manager = [DFLineCellManager sharedInstance];
 [manager registerCell:[DFShareLineItem class] cellClass:[DFShareLineCell class]];

TODO

  • 性能优化
  • 用户时间轴完善
  • 增加其它新的类型

ChangeLog

v1.3.0 重构cell管理模式 点击视频全屏播放

v1.2.9 增加发送图片 发送短视频

v1.2.8 加入pod

dftimelineview's People

Contributors

anyunzhong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dftimelineview's Issues

如何使用AFNetworking3.0

我想使用最新的AFNetworking;直接pod install之后,AFNetworking的版本是2.6的,我应该如何操作?

另外,除了pod install的方式加入工程以外,还有别的方法吗?比如直接copy到自己工程,手动添加需要的第三方库?

视频下移

录制的视频,在DFVideoCaptureController播放的时候,镜头有稍微的下移(录制的时候把一个物品放进镜头中心位置,可是播放的时候物品不在中心了,有下移)。请问这个问题能解决么。。。

点击评论

点击评论时不能滚到相应cell的底部(输入框不能和cell的底部链接)

视频解码造成内存警告

在iOS设置上发送视频解码不会造成内存警告,但是安卓发送视频,在iOS设备上出现内存警告.并且多次显示朋友圈界面的时候,内存还在一直往上涨

个人页面里面的问题

就是个人页面里面已经有了点击每个动态的方法,图片是不能放大的。有没有接口方法可以让个人页面里面的图片可以放大,纯文字就显示一个新的页面看到评论。像微信那样,如果没有,您有什么介意我解决这个问题呢。初学不久,很喜欢这个库,望回复。多谢大神

run error

diff: /../Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

DFCommon版本有问题

pod下来库,DFCommon版本最新的1.2.6是不是删除或修改了DFEmotionsManager等文件,编译不通过,我看你那版本锁定的是1.1.0

键盘

第三方键盘 键盘弹出高度

运行错误

Undefined symbols for architecture arm64:
"OBJC_CLASS$_DFTextImageLineItem", referenced from:
请问怎么解决

pod 库冲突,

请问 使用的AFNetWorking 不支持3.1.0? 非要用2.6.0?

  • AFNetworking (~> 3.1.0) required by Podfile
  • AFNetworking (~> 2.6.0) required by DFTimelineView (1.3.3)

pod install 失败,应该修改 podfile

如图,我的 pod 版本是1.1.1.直接 pod install 失败,检查了一下 podfile. 应该改一下:

platform :ios, '7.0'
target 'DFTimelineView' do
pod 'DFCommon'
end

这样修改了,重新安装的话就行了.

Demo里的文件似乎有问题

解压后没有正常的xcworkspace文件,只有xcodeproj文件。
image
pod update后报错:
Analyzing dependencies
[!] The dependency DFCommon is not used in any concrete target.

求助下应该怎么办呢?

运用错误

pod 'DFTimelineView'之后,编译一直报错lame/lame.h MLLabel+Size.h找不到文件,有遇到过的没,大虾们

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.