[英]UIImageView does not load image from URL iphone
I have imageView i want to load image from url but it is not loading i am using following code 我有imageView我想从网址加载图像,但它没有加载我使用下面的代码
pdfView.hidden=NO;
webView.hidden=NO;
pictureImageView.hidden=NO;
pdfView.backgroundColor=[UIColor clearColor];
doneButton = [[UIBarButtonItem alloc]initWithTitle:@" Done " style:UIBarButtonItemStyleBordered target:self action:@selector(doneButtonClick)];
self.navigationItem.leftBarButtonItem =doneButton;
webView.backgroundColor=[UIColor clearColor];
NSLog(@"File Name is %@",fileName);
NSLog(@"Enterning in the ImageSection");
NSString *ImageURL = fileName;
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:ImageURL]];
pictureImageView.image = [UIImage imageWithData:imageData];
Instead of this if i want to give from local like below then also it does not show image in imageView any idea how to load image from url thank 而不是这个,如果我想从本地给像下面那么它也没有在imageView中显示图像任何想法如何从url加载图像谢谢
pictureImageView.image=[UIImage imageNamed:@"starblue.png"];
首先设置该图像的帧,然后在pictureImageView
添加图像后写入该行
[self.view bringSubviewToFront:pictureImageView];
Code looks fine 代码看起来很好
Things to check 要检查的事情
UIImageView *pictureImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 20, 50, 50)];
Then do the rest 然后做其余的事
This is synchronous image loading that will block the main thread activities.Prefer to use asynchronous image download using AFNetworking or AsynchImageview 这是同步图像加载,将阻止主线程活动。优先使用AFNetworking或AsynchImageview使用异步图像下载
Use this code for show image in Url . 使用此代码在Url中显示图片。
NSString *image=[NSString stringWithFormat:@"Your URL"] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSLog(@"%@",image);
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:image]];
Yourimageview=[UIImage imageWithData:imageData];
pictureImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgurl]]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.