Ios Xcode tableview单元格无法通过url显示图像

Ios Xcode tableview单元格无法通过url显示图像,ios,objective-c,iphone,xcode,uitableview,Ios,Objective C,Iphone,Xcode,Uitableview,我遵循基于此处的代码,并在tableview中成功地显示了一些内容 我想通过使用网站的url链接更改单元格图像 这是我的密码: NSString *str = [NSString stringWithFormat:@"http://piq.codeus.net/static/media/userpics/piq_126382_400x400.png"]; NSString *path = [str stringByReplacingOccurrencesOfString:@"," withStr

我遵循基于此处的代码,并在tableview中成功地显示了一些内容

我想通过使用网站的url链接更改单元格图像

这是我的密码:

NSString *str = [NSString stringWithFormat:@"http://piq.codeus.net/static/media/userpics/piq_126382_400x400.png"];
NSString *path = [str stringByReplacingOccurrencesOfString:@"," withString:@"/"];

NSURL *url = [NSURL URLWithString:path];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
cell.imageView.image = [UIImage imageWithData:data];
如果我把str改成 NSString*str=@https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSrKOobbDUVMwrrqMkpvfhITeyQewM8Kj0fZg_X_u3TaM-CLi5QfA; 然后,它将成功更改表视图中每个单元格的图像


两个URL链接到同一个图像,但第一个链接图像大小大于第二个链接。

问题已解决。感谢@GoodSp33d。 适用于使用Xcode 7的用户。请参阅

这是我的更新代码:

NSString *str = [NSString stringWithFormat:@"your image url"];
NSURL *url = [NSURL URLWithString:str];
NSData *data = [NSData dataWithContentsOfURL : url];
cell.imageView.image = [UIImage imageWithData:data];

您使用的是Xcode 7吗?默认情况下,HTTP URL可能会被阻止。实际上你称之为同步,它需要一些时间delay@GoodSp33d,是的,我使用的是xcode 7。我能做些什么来解锁它?@Anbu.Karthik,但我确实等了很长时间,仍然没有图像出现。请检查我评论中的相关问题。干得好: