我给了 100条数据 就是显示了 4条数据
cocfident opened this issue · comments
我给了 100条数据 就是显示了 4条数据 numberOfLines 我设置的 2, 就显示了两排 数据
弹幕是不会碰撞的,发送服务器的弹幕不用这个函数接口[self.danmakuView sendDanmaku:model forceRender:YES],demo注释里面有详细的描述,numberOfLines设置2表示只显示两行,弹幕2s内没显示都会过滤掉,可以设置HJDanmakuConfiguration对象里面tolerance属性,增大弹幕的过期时间
我设置 config.tolerance = 10; 然后isPrepared 一直是no,- (void)prepareCompletedWithDanmakuView:(HJDanmakuView *)danmakuView 这个方法也不回掉了
你先看下代码,我现在还不是很清楚你的调用逻辑
-
(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];
}
}
sendDanmakus 是在prepare函数后面调用的,初始化弹幕可以通过prepared函数传入,你这都没有调用prepare函数,你先看下demo
改成了[self.danmakuView prepareDanmakus:arr]; 也设置了config.tolerance = 600; 现在只显示 2条数据了, model里面的time 要设置么, 这个参数做什么的