3

Ok, I got this issue: I have an application with a login screen that is suposed to show everytime the app goes to background and return. The problem is, the previous screen appears for a fraction of second after the app return to foreground, because the system only refresh what is being seen after loading. What is need is a complete transition before the app returns to foreground. Yes, I am doing the transition on app delegate, at applicationDidEnterBackground. tried at every single other back/fore transition method, same results. The code works fine, but theres a flash of the screen before the login screen showing up.

The full code is as follows:

    - (void)applicationDidEnterBackground:(UIApplication *)application
       {               
           if (!([LogicCore loadPass] == nil || [[LogicCore loadPass] isEqualToString:@""])) //a password is set, 
           {
               [self.window.rootViewController dismissModalViewControllerAnimated:YES];//go back to the rootview, the login screen

           }
       }
Stephen Lynx
  • 1,077
  • 2
  • 14
  • 29
  • Have you tried putting your code in `applicationWillResignActive:`? There was a question with a bounty on this same topic [Changing UIView when applicationWillEnterForeground fires](http://stackoverflow.com/q/7569187/590956). I think you will need to make a change to the UI before the app is backgrounded because I'm fairly certain that the iOS takes a screenshot of the app that is shown until the app is full screen and then you see your changes (thus the flicker). Note that I successfully made changes in `applicationWillResignActive:`, but haven't tried changing views as you are doing. – Sam Nov 03 '11 at 14:39
  • put the code at applicationWillresignActive, same results. – Stephen Lynx Nov 03 '11 at 14:49
  • 1
    I just filed this bug with apple: [Can't Update UI when App Returns from Background](https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/5/wo/3oZ6Z2gT1hIK2kHEXQ1zO0/8.66) – Sam Nov 03 '11 at 15:15

2 Answers2

1

I forgot about this, but you can have your app exit when the user backgrounds it. The only real problem here is they see your splash screen again while the app loads.

To have your app exit when backgrounded (suspended) put the key "Application does not run in background" - raw key: UIApplicationExitsOnSuspend to YES.

Not an ideal solution, but the only one I can find at the moment.

Sam
  • 26,946
  • 12
  • 75
  • 101
0

Try making the call in applicationWillEnterForeground: which "lets you know that your app is moving out of the background and back into the foreground, but that it is not yet active."

You're doing it after the transition has occurred (the change will be "queued" to happen after displaying the view)—you want to do it before, so you go with the will methods.

FeifanZ
  • 16,250
  • 7
  • 45
  • 84
  • Pretty sure this won't work. Seems as though apple iOS takes a snapshot of the app that is shown. I've tested this in the past, and as soon as the app is in full focus (watch the snapshot grow to full size of screen) then the changes you made will instantly appear. – Sam Nov 03 '11 at 14:34