简体   繁体   English

如何在iPhone的图像视图中加载URL图像

[英]how to load url image in image view in iphone

- (void)viewDidLoad
   {
    [super viewDidLoad];
    NSURL *url = [NSURL URLWithString:@"http://www.scri8e.com/effects/FL0WERZ/PNG/ir09.png"];
    data = [[NSData alloc]initWithContentsOfURL:url ];
    UIImage *img = [[UIImage alloc]initWithData:data ];
    imageview.image=img;
    }

above is my code but it does not load the image in image view 上面是我的代码,但是它不会在图像视图中加载图像

试试这个库,它将帮助您下载图像并显示在imageview中。

The same code working for me fine !!!!!! 相同的代码对我来说很好!!!!!!!

Please check the Internet Connection. 请检查互联网连接。

Please check the NSData *data size 请检查NSData *data大小

Please check the UIImageView Size 请检查UIImageView大小

Please check it hided by some other controls 请检查是否被其他控件隐藏

Please check it added properly to your View 请检查它是否已正确添加到您的视图中

Please check its Content View 请检查其内容视图

@property(nonatomic,retain) IBOutlet UIImageView *imageview;

NSURL *url = [NSURL URLWithString:@"http://www.scri8e.com/effects/FL0WERZ/PNG/ir09.png"];
NSData *data = [[NSData alloc]initWithContentsOfURL:url ];
UIImage *img = [[UIImage alloc]initWithData:data ];
self.imageview.image=img;

如果直接在xib中拍摄了imageview,则不只是在连接检查器中检查连接。

使用EgoImageView而不是ImageView。

NSString *mainimg=[NSString stringWithFormat:@"%@",[[xmlDataDictionary valueForKeyPath:@"eg.main.img1"]objectAtIndex:indexPath.row]];
NSURL *url = [NSURL URLWithString:mainimg];
NSData *image = [[NSData alloc] initWithContentsOfURL:url];
cell.img.image=[UIImage imageWithData:image];

Try this for parsed url.. 试试这个解析的URL。

So simple.. 很简单..

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *url_Img1 = @"http://www.scri8e.com/effects/FL0WERZ/PNG";
    NSString *url_Img2 = @"ir09.png";

    NSString *url_Img_FULL = [url_Img1 stringByAppendingPathComponent:url_Img2];

    NSLog(@"Show url_Img_FULL: %@",url_Img_FULL);
    _view_Image.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url_Img_FULL]]];

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM