2016-03-11 114 views
0

爲了(至少部分)保護我的應用程序中顯示的數據的安全,我希望用戶每次查看應用程序時都要登錄。我有一個名爲Keeper的類似應用程序,需要在應用程序第一次打開時以及用戶將應用程序從後臺運行時重新登錄,但不同之處在於,當它從後臺返回時,會在用戶重新啓動之前的視圖登錄。我將如何處理此要求?我只想使用touchID,但實際上我想我會使用4位密碼作爲備份。謝謝!如何在每次出現應用程序時要求登錄

+0

查看UIApplicationDelegate的生命週期委託方法。 – Eiko

+0

在AppDelegate類的enterForground方法中將login view controller設置爲window.rootviewcontroller –

回答

0

在appDelegate的「applicationDidBecomeActive:」方法中調出您的登錄對話框。

1
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 

    showLoginView() 

    return true 
} 

func applicationWillEnterForeground(application: UIApplication) { 

    // This gets called when the app comes back from Background 
    showLoginView() 
} 

func applicationDidBecomeActive(application: UIApplication) { 

    // NOTE: You don't want to call showLoginView() here 
    // Because this gets called even when the app becomes active after user drags down Notification Center, or drags up Utility Panel. 
} 
相關問題