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

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 /// @param imageUrl
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl { - (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl {
NetImageConfig *config = [[NetImageConfig alloc]init]; NetImageConfig *config = [[NetImageConfig alloc]init];
config.autoLoad = NO; ///
config.autoLoad = YES;
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config]; NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
UIImage* image = imageView.image; UIImage* image = imageView.image;
if (image) { if (image) {

View File

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