Monotouch:控制器带到前台 - 通知?

Ian*_*ink 4 notifications foreground xamarin.ios

MonoTouch的

当应用程序返回到前台时,我需要处于活动状态的ViewController来了解这一点.

是否有事件或覆盖我可以用来确定视图被带到前台.

我确实找到了"WillEnterForegroundNotification",但它是一个String,所以我不确定它是如何使用的.

Ian*_*ink 8

我找到了这个:

把它放在ViewController的CTOR中:

NSNotificationCenter.DefaultCenter.AddObserver (UIApplication.WillEnterForegroundNotification, 
    EnterForeground); 
Run Code Online (Sandbox Code Playgroud)

然后创建此方法以处理视图控制器中的事件.

void EnterForeground (NSNotification notification)
{
    Console.WriteLine("EnterForeground: " + notification.Name); 
}
Run Code Online (Sandbox Code Playgroud)

注意:当您的应用程序被带到前台时,UIApplicationDelegate将首先获得此项,这是清除登录详细信息和安全相关检查等内容的好地方.

public override void WillEnterForeground (UIApplication application)
Run Code Online (Sandbox Code Playgroud)