Areeba Khan Areeba Khan - 4 months ago 11
iOS Question

How to display image on UIImageView using URL and NSString in ios?

I want to display image on

using URL and
. I am unable to show image.

My code is:

UIImageView *view_Image = [[UIImageView alloc]initWithFrame:CGRectMake(view_Image_Pos_X, view_Image_Pos_Y, 179, 245)];

view_Image.backgroundColor = [UIColor greenColor];
view_Image.tag = img;
view_Image.autoresizesSubviews = YES;
view_Image.alpha = 0.93;
[self.view addSubview:view_Image];

Here what i am trying:

if (img == 0) {

NSString *url_Img1 = @";";
NSString *url_Img2 = @"45djx96.jpg";

NSString *url_Img_FULL = [NSString stringWithFormat:@"%@%@", url_Img1,url_Img2];

NSLog(@"Show url_Img_FULL: %@",url_Img_FULL);

NSURL *url_img = [NSURL URLWithString:url_Img_FULL];
NSLog(@"Show: url_img %@",url_img);

// Here below line working perfectly and image is showing

view_Image.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@""]]]; // working code

but i dont want this i want to concatanate two url make one url(ie;url_Img_FULL) and then pass to an image like below:

UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url_Img_FULL]]]; // Not Working

I Want from "url_Img_FULL" (ie: combination of two url) The image will show.
You can check also the url is working properly.
Any idea?

    NSString *url_Img1 = @"";
    NSString *url_Img2 = @"45djx96.jpg";

    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]]]; 

try this.