Objective c 如何从iOS中的url内容获取url图像。帮助我?

Objective c 如何从iOS中的url内容获取url图像。帮助我?,objective-c,ios,uiimageview,nsurl,Objective C,Ios,Uiimageview,Nsurl,我对如何从URL获取图像有问题 我试过: NSURL *url=[NSURL URLWithString:[NSString stringwithFormat:@"http://kenh14.vn/c102/20120715022212850/ngoc-trinh-la-model-thi-khong-nen-ngai-the-hien.chn"]]; NSURLRequest *request=[NSURLRequest requestWithURL:url]; NSURLConnection

我对如何从URL获取图像有问题

我试过:

NSURL *url=[NSURL URLWithString:[NSString stringwithFormat:@"http://kenh14.vn/c102/20120715022212850/ngoc-trinh-la-model-thi-khong-nen-ngai-the-hien.chn"]];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
NSURLConnection *connection=[[NSURLConnection alloc]initWithRequest:request delegate:self startImmediately:NO];
[connection start];

NSData *data=[NSURLConnection sendSynchrounousRequest:request returningResoibse:nil error:nil];
我想在
UIImageView
中使用此图像

UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
苹果的示例代码可能就是您想要的。祝你好运


苹果的示例代码可能就是您想要的。祝你好运。

你好像在问如何让一个
UIImageView
只显示在网站上找到的图像。(上面列出的URL不是指向图像,而是指向网站)

这是非常不切实际的,但我想还是有可能的。我个人不知道如何做到这一点,但这个链接可能会帮助你

然而,如果您希望简单地从自己的URL显示一个图像,这可以很容易地完成

e、 x:

如果完全以编程方式创建
UIImageView

UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/images/srpr/logo3w.png"]]]];
[self.view addSubview:myImageView];
如果您的图像视图在其他位置实例化,并且您只想将图像应用于它:

[myImageView setImage: [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/images/srpr/logo3w.png"]]]];

您似乎在问如何使
UIImageView
只显示网站上的图像。(上面列出的URL不是指向图像,而是指向网站)

这是非常不切实际的,但我想还是有可能的。我个人不知道如何做到这一点,但这个链接可能会帮助你

然而,如果您希望简单地从自己的URL显示一个图像,这可以很容易地完成

e、 x:

如果完全以编程方式创建
UIImageView

UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/images/srpr/logo3w.png"]]]];
[self.view addSubview:myImageView];
如果您的图像视图在其他位置实例化,并且您只想将图像应用于它:

[myImageView setImage: [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/images/srpr/logo3w.png"]]]];

谢谢。我想从网站下载图像列表并显示。请帮助我。谢谢。我想从网站下载图像列表并显示。请帮助我。谢谢。我想从网站下载图像列表并显示。请帮助我。@user1528296 plz检查更新。示例代码将非常有用。@user1528296如果这是您想要的,您可以接受以下答案:)谢谢。我想从网站下载一个图像列表并显示它。请帮助我。@user1528296请检查更新。示例代码将非常有用。@user1528296如果这是您想要的,您可以接受以下答案:)