it\'s my first question here as I have a problem developing my first iOS app. It is one of the thousands of flashlight apps, however I\'m trying to put as many features as p
I only have an answer as to why a quick stop start of the App will display a black screen, I have no reference only personal experience and observation.
When the App is sent to the background the OS attempts to take a screen shot to use instead of the Default.png
. If you start the App before a screenshot is taken and you don't have a Default.png
in your project then you will get that.
Still thinking about your actual question.
According to the iOS App Programming guide:
Returning to the foreground is your app’s chance to restart the tasks that it stopped when it moved to the background. The steps that occur when moving to the foreground are shown in Figure 3-6. The applicationWillEnterForeground: method should undo anything that was done in your applicationDidEnterBackground: method, and the applicationDidBecomeActive: method should continue to perform the same activation tasks that it would at launch time.
Have you tried re-applying your settings in the applicationDidBecomeActive:
method instead of the applicationWillEnterForeground:
?
Another thing to consider is working with notifications:
In the applicationDidBecomeActive:
or applicationDidBecomeActive:
methods of the AppDelegate, you can tell your app delegate to dispatch notifications to your controllers:
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
// Dispatch notification to controllers
[[NSNotificationCenter defaultCenter] postNotificationName: @"didBecomeActive"
object: nil
userInfo: nil];
}
Once you have this, the view controller can register for these notifications (in their init method, for example) like so:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(loadSettings)
name: @"didBecomeActive"
object: nil];
This way, your controller is aware that the app just became active and can execute any method you want.
In this example, you are telling your view controller to execute the loadSettings
method when it receives the didBecomeActive
notification (which was posted by the app delegate).