I have following storyboard. There is an OrderViewController
and when I open the app first time, it calls -(void) viewWillAppear: (BOOL) animated
method, but when I open another app (putting this app in the background), and then coming back to this app again, viewWillAppear
method is not getting called again?
Asked
Active
Viewed 709 times
1
-
yes, that is correct. – luk2302 Aug 06 '17 at 17:29
1 Answers
7
You sent the viewWillAppear
message when your view is added to the window's view hierarchy.
The window's view hierarchy doesn't change when the app moves from the background to foreground, so the message isn't sent for that event.
If you want to know (in your view controller) when your app is coming to the foreground, you should listen for either the UIApplicationWillEnterForeground
notification or the UIApplicationWillBecomeActive
notification (or both), depending on your precise needs.
Read “Strategies for Handling App State Transitions” in the App Programming Guide for iOS for more information about when these notifications are sent.

Forge
- 6,538
- 6
- 44
- 64

rob mayoff
- 375,296
- 67
- 796
- 848