0
我最近開始了一個新項目,在成功設置登錄頁後,我出現了一個問題。登錄後呈現視圖控制器
如果我在有效憑據在文本字段中鍵入,我的應用程序應該做到以下幾點:
if (user) {
[self.delegate loginViewControllerDidLogin:self];
...
的「如果用戶」部分是指一切正常。經過幾個小時的搜索後,我得知我的[self.delegate loginViewControllerDidLogin:self];
應該在AppDelegate.m
文件中定義。在這裏,我寫了下面的代碼:
- (void)loginViewControllerDidLogin:(LoginViewController *)controller {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController * ViewController = [[UIViewController alloc] init];
[self.window addSubview:ViewController.view];
[self.window.rootViewController presentViewController:ViewController animated:YES completion:nil];
}
我的問題是,我無法定義視圖控制器在我的故事板,所以我不能與視圖控制器本身的代碼連接。
所以基本上我想應用在登錄後打開一個新的視圖控制器
爲什麼不能在故事板上定義ViewController? – psobko
我不知道如何......在ViewController.h中試過它,但即使在我將它導入AppDelegates.m文件後,它也無法識別它。 – Annoonny