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 7184741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:15:49+00:00 2026-05-28T18:15:49+00:00

I’m trying to manually force iOS to load a 2x version of an file

  • 0

I’m trying to manually force iOS to load a 2x version of an file image file. I’m doing this to save resources – I need that graphic for the iPhone version, and I want to use it at a scale of 1:1 for the iPad version.

To do this I can’t use initWithContentsOfFile because iOS gives my the x1 version even if I add x2 onto the filename. Instead, I use this code:

NSString *filename = [myImage filenameWithSuffix:@"@2x"];
UIImage *image = [[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:filename]] CGImage]
                                            scale:1.0
                                      orientation:UIImageOrientationUp];

UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

That works. I’m 100% sure that it’s picking up the x2 version (I changed that graphic to make sure).

However, when it’s displayed on the screen, at the correct size, it’s blurry. In fact, it looks like the x1 version blown up to 200%, so iOS is doing something odd to my image.

I have ensured that the images are being drawn on pixel boundaries.

UPDATE:

Even if I create another image file without the x2 suffix and use initWithContentsOfFile to load it, it’s still blurred. So this has nothing to do with how it’s being loaded.

Other than pixel misalignment, what can cause image degradation?

Note that I’ve taken a screenshot and compare the image to the original in Photoshop. It’s exactly the same size, so scaling isn’t the issue.

  • 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-28T18:15:50+00:00Added an answer on May 28, 2026 at 6:15 pm

    I’ve solved this issue, and I’m embarrassed to say that it was due to pixel alignment.

    I discovered that the iOS simulator can highlight misaligned images, and that proved that the images were indeed misaligned. I then logged the position of every view from the image upwards in order to find the one that was causing the problem. This snippet proved its weight in gold several times:

        NSLog(@"View details");
        UIView *view = theImageView;
        while (view)
        {
            NSLog(@"%@", view);
            view = [view superview];
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
In my XML file chapters tag has more chapter tag.i need to display chapters
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.