Reputation: 205
I have imageView i want to load image from url but it is not loading i am using following code
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
pictureImageView.image=[UIImage imageNamed:@"starblue.png"];
Upvotes: 1
Views: 446
Reputation: 3329
Use this code for show image in Url .
NSString *image=[NSString stringWithFormat:@"Your URL"] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSLog(@"%@",image);
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:image]];
Yourimageview=[UIImage imageWithData:imageData];
Upvotes: 1
Reputation: 20021
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
Upvotes: 1
Reputation: 3656
pictureImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgurl]]];
Upvotes: 0
Reputation: 20541
First set frame of that image and then write this line after add image in pictureImageView
[self.view bringSubviewToFront:pictureImageView];
Upvotes: 1