Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imageview not loading at all

In the viewcontroller.h I am doing this.

@property( nonatomic, strong)IBOutlet UIImageView*showLogo;

In the viewcontroller.m I am doing this.

   NSString*path=@"http://www.stboston.com/wp-content/uploads/2012/08/iStock_000004791880_1.jpg";

    NSURL *url = [NSURL URLWithString:path];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *img = [[UIImage alloc] initWithData:data ];

 _showLogo=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 500)];
     _showLogo.image=img;
like image 474
Neprocker Avatar asked Mar 15 '26 09:03

Neprocker


1 Answers

try loading it directly into the _showLogo.image

_showLogo=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 500)];
_showLogo.image = [UIImage imageWithContentsOfURL:@"http://www.stboston.com/wp-content/uploads/2012/08/iStock_000004791880_1.jpg"];
[self.view addSubview:_showLogo];

or

NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.stboston.com/wp-content/uploads/2012/08/iStock_000004791880_1.jpg"]];
_showLogo.image = [UIImage imageWithData:imageData];
[self.view addSubview:_showLogo];
like image 150
apollosoftware.org Avatar answered Mar 18 '26 00:03

apollosoftware.org



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!