-
Notifications
You must be signed in to change notification settings - Fork 454
Description
我自定义弹幕 有两个字段 姓名和 文本。
我在控制台抓取数据 发送和 代理方法都正确 这两个字段对应的内容 也对 。但是展示出来的 有时候会出现 姓名 一栏赋值成了 文本。 就会导致 用户姓名变成了文本。具体代码如下, 麻烦看下是什么原因
这个是接收的弹幕内容
[_renderer receive:[self QNliveBarrageViewSpriteDescriptorWithDirection:BarrageWalkDirectionR2L side:BarrageWalkSideDefault message:message]];
这个是返回 BarrageDescriptor 方法
-
(BarrageDescriptor *)liveBarrageViewSpriteDescriptorWithDirection:(BarrageWalkDirection)direction side:(BarrageWalkSide)side message:(ILVLiveCustomMessage *)message
{
NSString *actionParam = [[NSString alloc] initWithData:message.data encoding:NSUTF8StringEncoding];
JSONModelError *error = nil;
LiveBarrageModel *textModel = [[LiveBarrageModel alloc] initWithString:actionParam error:&error];
if (!textModel.is_colorv_barrage) {
return nil;
}NSString *userName = [NSString stringWithFormat:@"%@",textModel.u.name];
NSString *iconPath = [NSString stringWithFormat:@"%@",textModel.u.icon];
//如果是神秘富豪
if (textModel.hide.count) {
userName = [textModel.hide objectForKey:@"hide_name"];
iconPath = [textModel.hide objectForKey:@"hide_icon"];
}
BarrageDescriptor * descriptor = [[BarrageDescriptor alloc]init];
descriptor.spriteName = NSStringFromClass([BarrageWalkSprite class]);
descriptor.params[@"speed"] = @(100 * (double)random()/RAND_MAX+50);
descriptor.params[@"direction"] = @(BarrageWalkDirectionR2L);
descriptor.params[@"side"] = @(BarrageWalkSideDefault);
descriptor.params[@"viewClassName"] = NSStringFromClass([LiveBarrageView class]);
descriptor.params[@"iconUrl"] = iconPath;
descriptor.params[@"user_name"] = userName;
descriptor.params[@"text_content"] = textModel.text ?:@"";
descriptor.params[@"pendant_path"] = textModel.u.pendant_path;
descriptor.params[@"colors"] = textModel.color;
下面这几个是我自己家的
return descriptor;
}
下面是
-
(void)configureWithParams:(NSDictionary *)params
{
[super configureWithParams:params];self.nameLabel.text = [params objectForKey:@"user_name"];
self.titleLabel.text = [params objectForKey:@"text_content"]; 在这分别给name 和 title 赋值
[self.widgetImageView setImageWithCDNPath:[params objectForKey:@"pendant_path"] placeholderImage:nil];
[self.avatarImageView setImageWithCDNPath:[params objectForKey:@"iconUrl"] placeholderImage:[UIImage defaultIcon]];LiveBarrageColor *color = [[LiveBarrageColor alloc] initWithDictionary:[params objectForKey:@"colors"] error:nil];
NSString *nameColor = color.name.length >0 ? color.name : @"CCCCCC";
self.nameLabel.textColor = [UIColor hex_colorWithRGBHexString:nameColor];NSString *colorFront = color.back1.length > 0 ? color.back1 : @"#616161";
NSString *colorBack = color.back2.length > 0 ? color.back2 : @"626262";
self.bgColorLayer.colors = @[(__bridge id)[UIColor hex_colorWithRGBHexString:colorFront].CGColor , (__bridge id)[UIColor hex_colorWithRGBHexString:colorBack].CGColor];
}
奇怪的是 控制台输出的 name 和 title对应的数据都对 但是展示出来的弹幕 确是两个 title 。 这种问题 是偶现 的大约 四五次 可以试出来。 希望能解答我的疑惑 非常感谢