How do you register for UIApplicationWillEnterForegroundNotification in MonoTouch

I have a problem with the ViewWillAppear method for UIView not working when the application returns from the background. This is a problem, since the main screen of the application displays the values ​​that are extracted from the user settings, and if the user changed them when the application was in the background, I need to update the screen. I read that you need to register for UIApplicationWillEnterForegroundNotification using NSNotificationCenter.

How do you do it in MonoTouch? Or does anyone know an alternative way to ensure that the screen is constantly updated even when returning from the background?

+4
source share
1 answer

You can try something line by line:

//Register for the notification somewhere in the app NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillEnterForegroundNotification, EnteredForeground); //snip void EnteredForeground (NSNotification notification) { // do your stuff here } 

Keep in mind that you will need to do this for each view controller that you want to update when it arrives from the background!

+7
source

All Articles