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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:42:15+00:00 2026-05-17T21:42:15+00:00

I’m working on a project for the iPad where I’m trying to simulate the

  • 0

I’m working on a project for the iPad where I’m trying to simulate the rotation of a 3D-body with touch by switching pre-rendered images.

I’m not the sharpest man when it comes to memory management so I wonder if anyone has any tips on how to optimize this.

My solution now looks something like this:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [[event allTouches] anyObject];
CGPoint location = [myTouch locationInView:self.view];
int pictureIndex;
//Rough mapping of image to point on screen
if (location.x <= 384 ) {
    pictureIndex = (384 - location.x)/(768/rotatingPictures)+1;
}
else {
    pictureIndex = rotatingPictures - (location.x-384)/(768/rotatingPictures)+1;
}
[theImageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"image_%d.png", pictureIndex]]];

}

Is it efficient to load the images this way? Would it be better to load the images to an array first or something like that?

I would prefer to have all loading time at once and not while rotating.

  • 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-17T21:42:15+00:00Added an answer on May 17, 2026 at 9:42 pm

    The first critical piece of information is that imageNamed is hopeless! It is well-known to be a dog. It’s neither one thing or the other; it doesn’t cache well and it tends to build up too much memory use. (Google up 100s of articles on this.) So, that’s out.

    You will have to tell us exactly how many images you have, and exactly how big (KB or MB) each image is.

    Only then can one decide a successful strategy.

    To swap from one large image to another “properly”, if you are swapping huge images over and over and if you have to worry about memory, you do this...

    [hugeImage.image release];
    hugeImage.image = [[UIImage alloc] initWithContentsOfFile:
               [[NSBundle mainBundle]
               pathForResource:@"bodyPart"
               ofType:@"png"]];
    

    that will properly get rid of the previous image and bring in the next one. NEVER, EVER use imageNamed — it is specifically designed only for small (i.e. icon sized) interface-use (i.e., buttons, icons, etc) images.

    However again, nobody can help you until we know the precise number of images, and the precise size, and indeed how often per second or per minute you expect the images to be swapped. Hope it helps!

    —– You went on to say …

    “89 .png pictures ranging in size from about 70 K to 100 K”

    Good news, you’re going to have no problem whatsoever. You can easily load those, and you can even do it fast enough in real time to make a 20 – 30 fps animation.

    Simply do exactly what I say above each time you swap from one to another, and you’re done.

    (For the record, remember to load one first when you are initialising, so that the code fragment above works properly the “first time” it is used, you know. And if possible, release the last one when you’re done.) Cheers.

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

Sidebar

Related Questions

No related questions found

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.