2015-06-11 53 views
0

我有一個應用程序通過Oauth登錄到第三方API,但在成功獲取令牌後需要幫助刪除我的授權視圖。以下是我已經得到了IB: enter image description here如何解除OAuth視圖?

該應用程序與普通視圖控制器啓動,如果沒有的authToken呈現AuthView:

override func viewDidAppear(animated: Bool) { 
    super.viewDidAppear(animated) 
    if (myVars.authToken == "") { 
     let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
     let authVC = storyboard.instantiateViewControllerWithIdentifier("AuthViewController") as! AuthViewController 
     self.navigationController?.showViewController(authVC, sender: self) 
    } 

你點擊授權,它會打開Safari瀏覽器的URL ,您授權該應用程序,它將返回帶有令牌的回調URL,該令牌返回到authVC顯示的應用程序。但我似乎無法讓我的authVC隱藏。

任何建議將大大appreaciated。

回答

0

我得到一個新的ViewController實例,所以我不能展開它等。在AppDelegate中我得到了我現有的導航控制器&視圖

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { 
    let navigationController = application.windows[0].rootViewController as! UINavigationController 
    let authView = navigationController.visibleViewController 

然後我可以調用authView的正確實例,除其他事項外,解開SEGUE並得到我回到我平時的導航流的功能。

可能有更好的解決方案,但這是行之有效的。