Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:26:23+00:00 2026-05-14T03:26:23+00:00

My app has to load an image from a http server and displaying it

  • 0

My app has to load an image from a http server and displaying it into an UIImageView
How can i do that??
I tried this:

NSString *temp = [NSString alloc];
[temp stringwithString:@"http://192.168.1.2x0/pic/LC.jpg"]
temp=[(NSString *)CFURLCreateStringByAddingPercentEscapes(
    nil,
    (CFStringRef)temp,                     
    NULL,
    NULL,
    kCFStringEncodingUTF8)
autorelease];


NSData *dato = [NSData alloc];
 dato=[NSData dataWithContentsOfURL:[NSURL URLWithString:temp]];
 pic = [pic initWithImage:[UIImage imageWithData:dato]];

This code is in viewdidload of the view but nothing is displayed!
The server is working because i can load xml files from it. but i can’t display that image!
I need to load the image programmatically because it has to change depending on the parameter passed!
Thank you in advance.
Antonio

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:26:23+00:00Added an answer on May 14, 2026 at 3:26 am

    It should be:

    NSURL * imageURL = [NSURL URLWithString:@"http://192.168.1.2x0/pic/LC.jpg"];
    NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
    UIImage * image = [UIImage imageWithData:imageData];
    

    Once you have the image variable, you can throw it into a UIImageView via it’s image property, ie:

    myImageView.image = image;
    //OR
    [myImageView setImage:image];
    

    If you need to escape special characters in your original string, you can do:

    NSString * urlString = [@"http://192.168.1.2x0/pic/LC.jpg" stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
    NSURL * imageURL = [NSURL URLWithString:urlString];
    ....
    

    If you’re creating your UIImageView programmatically, you do:

    UIImageView * myImageView = [[UIImageView alloc] initWithImage:image];
    [someOtherView addSubview:myImageView];
    [myImageView release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight app that has to load an image dynamically, depending on
My app has some table cells that vary in height. The cells can also
I'm loading HTML-formatted content into my app from a web service, then plugging that
I am able to load a resource image, from drawable folder, into a bitmap
I have a UIImageView that I'd like to load with a picture coming from
Part of our web app has a little Ajax method that will load a
I maintain an application that has a .aspx page that loads on image from
I have a GUI app written in C++/CLI which has a load of configurable
Windows Phone 7.5 app. Designer has created Home.xaml in Blend that has 3 images(menu
I have a 3.1 xcode project that has been running my app just fine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.