Facebook profile picture not showing in UIImageView?

83 views Asked by At

I am building a facebook app. Where I have to show my friends profile picture. But the image is not showing all the time when I run my project. I have used the code like tha

NSString *url = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture? type=large",friendId];

NSData *imageUrl = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];


UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:imageUrl]];


imgView.frame = CGRectMake(100.0f,100.0f,200,200);


[self.view addSubview:imgView];

But when I am printing the url in log then it shows an url and if I go with this url in browser then It shows picture in the browser.

For printing the URL I used the code below:

NSLog(@"%@",url);
0

There are 0 answers