3

If I get an alert in my application and if I put application in background and press application icon to enter the application, a splash screen is displayed and then the alert pop up. Why splash screen appears? And if alert is not present and I put application in background and press application icon to enter the application, splash screen is not displayed.

sam
  • 451
  • 3
  • 10
  • 20

5 Answers5

6

First you have to make the UIAlertView a property in your class. In your AppDelegate Class you can implement the applicationDidEnterBackground: Method in wich you can put something like this:

[yourViewController.yourAlert dismissWithClickedButtonIndex:0 animated:NO];

This should dismiss the alert if your app enters the background. Hope this helps!

pmk
  • 1,897
  • 2
  • 21
  • 34
1

The splash screen is as @akshay1188 mentions, is the Default.png in your project file. The reason for it being displayed, based on my best assumption, is because the OS has not managed to take a screenshot of your App before you go back to it. See this answer to a StackOverflow question where it was discussed.

As for the UIAlertView, @pKoul's anwser got my upvote.

Community
  • 1
  • 1
Thomas Nadin
  • 1,167
  • 10
  • 22
0

If you want to dismiss all AlertViews programmatically you have to Remember a Reference to the currently shown Alterviews. I recommend a Singleton class where you ask for an AlertView and wich saves a Reference to the AlertView.

then you could use the

`- (void)applicationDidEnterBackground:(UIApplication *)application`

in your AppDelegate and call a Function on the Singleton Class, wich itself calls

[alert dismissWithClickedButtonIndex:0 animated:YES];

at all Alertviews.

Dennis Stritzke
  • 5,198
  • 1
  • 19
  • 28
0

Maybe you can use the notification posted UIApplicationDidEnterBackgroundNotification in any class that needs some cleanup before entering bg. Do not forget to remove the observer in dealloc.

    [[NSNotificationCenter defaultCenter] addObserver: self
                                             selector: @selector(cleanup:) 
                                                 name: UIApplicationDidEnterBackgroundNotification 
                                               object: nil]
Vincent Zgueb
  • 1,491
  • 11
  • 11
0

The splash screen is actually the launch image that you might be using as Default.png

akshay1188
  • 1,647
  • 2
  • 17
  • 35