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

  • SEARCH
  • Home
  • 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 8231725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:35:31+00:00 2026-06-07T17:35:31+00:00

I have some images I need to get from the web. Just using data

  • 0

I have some images I need to get from the web. Just using data from a URL.
They need to show correctly on Retina Display.
When I get the images from the web, they still look pixelated. I need to set the images’ scale to retina display (2.0), but I must be missing something.
Here’s what I did so far.

UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:@"http://www.msdomains.com/tmp/test.png"];

CGRect labelFrame = CGRectMake(0,0,64,64);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:labelFrame];
imageView.contentScaleFactor = [UIScreen mainScreen].scale;

[imageView setImage:img];
[self addSubview:imageView];
[imageView release];
  • 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-06-07T17:35:32+00:00Added an answer on June 7, 2026 at 5:35 pm

    Your code should work pretty much as-is. I don’t know what the original dimensions of your image were, but I’d guess they were 64×64 px. In order to scale down correctly, the original image would need to be 128×128 px.

    As a test, the following code correctly displayed my photo in Retina resolution on the Simulator, and on my iPhone 4:

    UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.seenobjects.org/images/mediumlarge/2006-08-19-native-lilac.jpg"]]];
    
    CGRect labelFrame = CGRectMake(0, 0, 375, 249.5);
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:labelFrame];
    
    [imageView setImage:img];
    [self.view addSubview:imageView];
    

    Note that the UIImageView is 375×249.5 points, which is half of the original (pixel) dimensions of the photo. Also, setting the contentScaleFactor didn’t seem to be necessary.

    (As an aside, I can’t see that specifying @2x on the URL will help, in this case, as the call to dataWithContentsOfURL: will return an opaque blob of data, with no trace of the filename left. It’s that opaque data that’s then passed to imageWithData: to load the image.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code using jQuery to use Ajax to get data from
I have some data retrieved from web in following format (in a stream): {parts:[
I have some images that need to change, based not only on hover, but
I have been working on a website that has some images that I need
I have some images, named SomeImage.png and SomeImage-hd.png( for retina). Everything looks with non-
In my application I am downloading some images from the web (from my server
i have some images that get displayed on a page, some of them don't
I have some data in the html format. I am using Html.fromHtml(String) when setting
I am getting image and some details from .net web server. I need to
So basically everyone at one point needs to do this,load some images from web

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.