3
votes

I am creating an app with functionality like a stopwatch. When the app moves to the background, iOS takes a snapshot, and when it moves back into the foreground it uses that snapshot for the animation while switching back to the app.

This means that if the app was backgrounded for 10 seconds, the stopwatch will have the wrong time (by 10 seconds) displayed during the opening animation.

Is there some way to stop iOS taking this snapshot, or stop iOS from using it when the app moves back to the foreground?

1

1 Answers

2
votes

You can not stop iOS from taking snapshot. But you can display and hide a temporary view using below notifications :

UIApplicationDidEnterBackgroundNotification

UIApplicationWillEnterForegroundNotification

The temporary view will be then taken as the snapshot.

   [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(displayTempView) name:UIApplicationDidEnterBackgroundNotification object:nil];
   [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hideTempView) name:UIApplicationWillEnterForegroundNotification object:nil];

   - (void) displayTempView {
         tempWebView.hidden = NO;
     }
   - (void) hideTempView {
         tempWebView.hidden = YES;
     }

Hope it helps.