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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:36:30+00:00 2026-06-10T09:36:30+00:00

I have 2 UIImageView’s in the main view controller of my app. They are

  • 0

I have 2 UIImageView’s in the main view controller of my app. They are always animating via UIView animations. What I want to achieve is when the user clicks the home button, pause the UIView animations, and when the user comes back to the app, resume the animations.

So to pause I call a method from my app delegate to my ViewController to pause in the applicationWillResignActive call.

And to resume I call a method also from the app delegate to my ViewController to resume in the applicationDidBecomeActive method.

This is the code I use to either pause or resume my animations:

-(void)pauseLayer:(CALayer*)layer {
    CFTimeInterval paused_time = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
    layer.speed = 0.0;
    layer.timeOffset = paused_time;
}

-(void)resumeLayer:(CALayer*)layer {
    CFTimeInterval paused_time = [layer timeOffset];
    layer.speed = 1.0f;
    layer.timeOffset = 0.0f;
    layer.beginTime = 0.0f;
    CFTimeInterval time_since_pause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - paused_time;
    layer.beginTime = time_since_pause;
}

- (void)pause:(BOOL)theBool {
    if (theBool) {
        [self pauseLayer:self.myImageView.layer];
        [self pauseLayer:self.myImageViewleft.layer];
    } else {
        [self resumeLayer:self.myImageView.layer];
        [self resumeLayer:self.myImageViewleft.layer];
    }
}

So I NSLogged everything and the methods get called accordingly however when I go to resume the animations, the image views don’t resume from where they left off and are most likely at the position I placed them in the XIB (off the screen).

So when I re-enter my app, does my XIB get reloaded or something? There is absolutely nothing that should be changing the position of those UIImageView’s, thats why I am really confused why this is happening.

Edit: I have also tried creating my images programmatically, no luck same issue. The pausing and resuming works successfully if I do it via buttons in my app while its running, it seems the problem is with the application delegate methods or something.

If anyone sees what’s wrong, please let me know!

  • 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-10T09:36:32+00:00Added an answer on June 10, 2026 at 9:36 am

    I found this to be really complicated and tricky so for now I will just use Cocos2D instead and make use of CCDirector’s pause feature.

    Edit: Just tried CCDirector’s pause feature and it works perfectly. Definitely go this route!!!

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

Sidebar

Related Questions

I have a UIImageView that I allocated inside of a UIView. I want to
I have a UIImageView property in my view controller set to assign. Every time
I have two UIImageView filling the view controller, the first is filling the top
I have two UIImageView objects inside my view (both 320x480 one above the other).
I have a UIImageView whose frame, set before the image is loaded, is always
I have a UIImageView inside of a UIScrollView. The parent scroll view allows zooming
I have UIImageView what have a role of a background image in View. I
I have a UIImageView whose image gets set via UIImagePicker - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary
I have a uiimageview and I want to move it while the animation of
I have a UIImageView that I want to add a shadow behind. I wish

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.