2012-08-23 53 views
0

我正在嘗試使用applicationDidBecomeActive方法(和類似的方法) - 我可以在ObjC中找到大量的示例,但Monotouch中沒有。 已經嘗試了AppDelegate和UIViewController中的重寫,但編譯器找不到合適的重寫方法。那麼,我該如何使用它? 我想使用它(與一個計時器和IdleTimerDisabled結合)來停止設備進入睡眠時間比平常更長(這是一個秒錶類型的應用程序)。也許我走錯了路。applicationWillBecomeActive在MonoTouch

回答

2

在從UIApplicationDelegate繼承了您的應用程序委託,您可以重寫這些:

/// <summary> 
/// Gets called by iOS if the app is started from scratch and is not resumed from background. 
/// We have 17 seconds to leave this methos before iOS will kill the app. 
/// </summary> 
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) 

/// <summary> 
/// Called if the app comes back from background or gets started. Triggered after FinishedLaunching(). 
/// </summary> 
public override void OnActivated (UIApplication application) 

/// <summary> 
/// Called if the application gets pushed to the background because the user hits the home button. 
/// </summary> 
public override void DidEnterBackground (UIApplication application) 

/// <summary> 
/// Gets called if the app is resumed from background but NOT if the app starts first time. 
/// </summary> 
public override void WillEnterForeground (UIApplication application) 
+0

感謝。其實我想我問了一個錯誤的問題,因爲每次按下按鈕時都需要刷新計時器,以保持設備的喚醒時間比平常長。這些覆蓋不會捕獲正確的事件,但你讓我走上了正確的軌道 - 現在我已經重寫了TouchUpInside,用於關鍵ViewController中的所有按鈕。 – quilkin