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

MonoTouch的

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

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

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

解决方法

我找到了这个:

把它放在ViewController的CTOR中:

NSNotificationCenter.DefaultCenter.Addobserver (UIApplication.WillEnterForegroundNotification,EnterForeground);

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

void EnterForeground (NSNotification notification)
{
    Console.WriteLine("EnterForeground: " + notification.Name); 
}

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

public override void WillEnterForeground (UIApplication application)

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...