我有一個應用程序,它有一個登錄導航控制器和一個標籤欄控制器。我已經將我的標籤欄控制器設置爲根控制器,但是我希望登錄導航控制器顯示爲模式,以便在登錄時可以將其解除,而如果是的話,則可以不顯示它。它正在閱讀正確的內容,但未能提供landingviewcontroller
。當我運行應用程序時,它直接跳轉到TabBarController。作爲模態iOS呈現登錄?
我的代碼如下:
我有檢查,如果你是在我的應用程序委託這是我要告訴它呈現着陸視圖控制器(登錄)登錄的方法。我從步進通過其正確判斷,我不是在登錄和去這行代碼上運行的知道:
[self.window.rootViewController presentViewController:landingVC animated:YES completion:nil];
完整的應用程序的委託:
#import "GFAppDelegate.h"
#import "GFCredentialStore.h"
@implementation GFAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
UIViewController *tabBarController = [storyboard instantiateInitialViewController];
UIViewController *landingVC = [storyboard instantiateViewControllerWithIdentifier:@"LandingViewController"];
GFCredentialStore *store = [[GFCredentialStore alloc] init];
if (store.isLoggedIn) {
self.window.rootViewController = tabBarController;
} else {
[self.window.rootViewController presentViewController:landingVC animated:YES completion:nil];
}
// Set root view controller and make windows visible
[self.window makeKeyAndVisible];
return YES;
}
我試着要清楚這一點,但要理解這可能是因爲寫得不好而令人困惑。謝謝你的幫助。
非常感謝。完美的作品。任何想法我可以在loginViewController中解僱這個,我必須導入「AppDelegate」或創建一個ViewController的新實例,以在單獨的控制器中訪問它。 – jckly
[self dismissViewControllerAnimated:YES completion:nil]; - 在loginViewController – xexe
再次感謝!整理出來。 – jckly