2016-08-17 59 views
0

我有一個視圖呈現爲從AppDelegate中形式表與此代碼:等待形式片 - 的iOS

let storyboard = UIStoryboard(name: "Main", bundle: nil) 
let usernameVC = storyboard.instantiateViewController(withIdentifier: "ChooseUsernameViewControllerID") 
usernameVC.modalPresentationStyle = .formSheet 
self.window?.rootViewController?.present(usernameVC, animated: true, completion: nil) 

後我提出它我不得不等待窗體表之前繼續被駁回執行代碼...我如何暫停執行代碼,直到表單被解除?

PS。要執行的代碼是:

UIView.transition(with: self.window!, duration: 0.3, options: UIViewAnimationOptions.transitionFlipFromRight, animations: { 
       self.window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainContainerViewControllerID") 
       }, completion: nil) 
+0

什麼代碼執行? – Catoshi

+0

@TonyHan我編輯了這個問題 – ale00

回答

0

什麼你想在這裏做的,是添加一個委託到你的ChooseUsernameViewController,用了一個方法。該方法應該被稱爲「ChooseUsernameDisappeared」或類似的東西。然後,將一個viewDidDisappear方法添加到ChooseUsernameViewcontroller,並在調用此方法時觸發該委託。然後,在您的AppDelegate中實現ChooseUsername委託來偵聽失蹤。然後,您可以執行代碼。