Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我给了 100条数据 就是显示了 4条数据 #19

Open
cocfident opened this issue Mar 5, 2019 · 6 comments
Open

我给了 100条数据 就是显示了 4条数据 #19

cocfident opened this issue Mar 5, 2019 · 6 comments

Comments

@cocfident
Copy link

我给了 100条数据 就是显示了 4条数据 numberOfLines 我设置的 2, 就显示了两排 数据

@panghaijiao
Copy link
Owner

弹幕是不会碰撞的,发送服务器的弹幕不用这个函数接口[self.danmakuView sendDanmaku:model forceRender:YES],demo注释里面有详细的描述,numberOfLines设置2表示只显示两行,弹幕2s内没显示都会过滤掉,可以设置HJDanmakuConfiguration对象里面tolerance属性,增大弹幕的过期时间

@cocfident
Copy link
Author

我设置 config.tolerance = 10; 然后isPrepared 一直是no,- (void)prepareCompletedWithDanmakuView:(HJDanmakuView *)danmakuView 这个方法也不回掉了

@panghaijiao
Copy link
Owner

你先看下代码,我现在还不是很清楚你的调用逻辑

@cocfident
Copy link
Author

  • (void)viewDidLoad {
    [super viewDidLoad];

    HJDanmakuConfiguration *config = [[HJDanmakuConfiguration alloc] initWithDanmakuMode:HJDanmakuModeLive];
    config.numberOfLines = 2;
    config.cellHeight = 30;
    config.tolerance = 3;

    _danmakuView = [[HJDanmakuView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 200) configuration:config];
    _danmakuView.delegate = self;
    _danmakuView.dataSource = self;
    [_danmakuView registerClass:[AJBarrageCell class] forCellReuseIdentifier:@"cell_key"];

    [self.view addSubview:_danmakuView];

    NSMutableArray *arr = [NSMutableArray array];

    for (int i = 0; i < 100; i++) {
    AJBarrageModel *model = [[AJBarrageModel alloc] initWithType:HJDanmakuTypeLR];
    model.text = [NSString stringWithFormat:@"我是弹幕-------%d号",i];
    [arr addObject:model];
    }
    [self.danmakuView sendDanmakus:arr];

}

  • (IBAction)play:(id)sender {

    if (self.danmakuView.isPrepared) {
    [self.danmakuView play];
    }

}

@panghaijiao
Copy link
Owner

sendDanmakus 是在prepare函数后面调用的,初始化弹幕可以通过prepared函数传入,你这都没有调用prepare函数,你先看下demo

@cocfident
Copy link
Author

改成了[self.danmakuView prepareDanmakus:arr]; 也设置了config.tolerance = 600; 现在只显示 2条数据了, model里面的time 要设置么, 这个参数做什么的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants