首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ios如何将UIImage添加到UITextView异步?

ios如何将UIImage添加到UITextView异步?
EN

Stack Overflow用户
提问于 2014-10-22 12:34:46
回答 1查看 861关注 0票数 1

我可以使用UIImageView+AFNetworking异步地分别添加图像

[imageView setImageWithURL:[NSURL URLWithString:[self.data valueForKey:@"image_link"]]];

我还可以通过以下方式向UITextView添加图像

代码语言:javascript
复制
UITextView *text = [[UITextView alloc] init];
UIImageView *imageView = [UIImageView new];
[imageView setImage:[UIImage imageNamed:@"image.png"]];
CGRect aRect = CGRectMake(0, 0, 125, 120);
[imageView setFrame:aRect];

UIBezierPath *exclusionPath = [UIBezierPath bezierPathWithRect:aRect];
text.textContainer.exclusionPaths = @[exclusionPath];
[text addSubview:imageView];

但是我不能在UITextView中异步地添加图像,比如

代码语言:javascript
复制
UITextView *text = [[UITextView alloc] init];
UIImageView *imageView = [UIImageView new];
[imageView setImageWithURL:[NSURL URLWithString:[self.data valueForKey:@"image_link"]]];
CGRect aRect = CGRectMake(0, 0, 125, 120);
[imageView setFrame:aRect];
UIBezierPath *exclusionPath = [UIBezierPath bezierPathWithRect:aRect];
text.textContainer.exclusionPaths = @[exclusionPath];
[text addSubview:imageView];

那么,如何在UITextView中异步添加图像呢?

EN

回答 1

Stack Overflow用户

发布于 2014-10-22 13:14:35

使用调度:

代码语言:javascript
复制
dispatch_async(dispatch_get_main_queue(), ^{
       // async UI update here
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26507571

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档