送多个礼物崩溃 没时间看了 先这样吧

This commit is contained in:
fengshuo
2021-12-02 01:05:49 +08:00
committed by zu
parent 33dd1bb3d4
commit a351b52eba
2 changed files with 18 additions and 17 deletions

View File

@@ -367,7 +367,8 @@
/// @param imageUrl
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl {
NetImageConfig *config = [[NetImageConfig alloc]init];
config.autoLoad = NO;
///
config.autoLoad = YES;
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
UIImage* image = imageView.image;
if (image) {

View File

@@ -13,22 +13,22 @@
- (void)setAttributedText:(NSAttributedString *)attributedText {
NSUInteger length = attributedText.length;
NSAttributedString* attributedTextCopy = [attributedText mutableCopy];
for (int i = 0; i < length; i++) {
YYTextAttachment* attachment = [attributedText yy_attributesAtIndex:i][YYTextAttachmentAttributeName];
if (!attachment || ![attachment.content isKindOfClass:[NetImageView class]]) continue;
NetImageView* imageView = attachment.content;
if (!imageView.imageUrl) continue;
if (imageView.state == NetImageStateLoaded) {
attributedTextCopy = [self updateNetImageAttribute:imageView attributes:attributedTextCopy index:i];
continue;
}
[imageView loadImage:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
imageView.image = image;
[super setAttributedText:[self updateNetImageAttribute:imageView attributes:self.attributedText index:i]];
}];
}
// for (int i = 0; i < length; i++) {
// YYTextAttachment* attachment = [attributedText yy_attributesAtIndex:i][YYTextAttachmentAttributeName];
// if (!attachment || ![attachment.content isKindOfClass:[NetImageView class]]) continue;
// NetImageView* imageView = attachment.content;
// if (!imageView.imageUrl) continue;
//
// if (imageView.state == NetImageStateLoaded) {
// attributedTextCopy = [self updateNetImageAttribute:imageView attributes:attributedTextCopy index:i];
// continue;
// }
// //TODO
//// [imageView loadImage:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
//// imageView.image = image;
//// [super setAttributedText:[self updateNetImageAttribute:imageView attributes:self.attributedText index:i]];
//// }];
// }
[super setAttributedText:attributedTextCopy];
}