для ios, target-c, здесь хотелось бы загрузить html-файл (aa.html) в UITextView, но я хотел бы сохранить URL-адрес изображения при выполнении преобразования для целей перезагрузки, но, похоже, он сокращаетсяссылка.Жду помощи.Большое спасибо.Ниже приведен код:
// aa.html is my local html format file
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"aa" ofType:@"html"];
NSString *htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]
initWithData: [htmlString dataUsingEncoding:NSUTF8StringEncoding]
options: @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}
documentAttributes: nil
error: nil
];
// retrieve image here
[attributedString enumerateAttribute:NSAttachmentAttributeName
inRange:NSMakeRange(0, [attributedString length])
options:0
usingBlock:^(id value, NSRange range, BOOL *stop)
{
// when it is NSTextAttachment(kind of image)
if ([value isKindOfClass:[NSTextAttachment class]])
{
NSTextAttachment *attachment = (NSTextAttachment *)value;
//the complete url is shorten after Encoding
// the attachment here can only show "bb.jpg", but what i expect is the full url like: https://attach.mobile01.com/attach/201811/bb.jpg
}
}];