2017-01-22 3 views
1

私は5つのタブを含むタブバーを持っています。私のアプリケーションでは、ユーザーはログインする必要はありません。ユーザーがサインアップまたはログインすると、一部の機能のみが許可されます。Skip Login NavControllerのコントローラを表示

ユーザがすでに登録/ログインしている場合、NavigationControllerに接続されているUserViewControllerに次のロジックを実装しました。しかし、次のロジックでは、ユーザーは1秒〜2秒でViewControllerを見ることができました。

-(void) viewWillAppear: (BOOL) animated 
{ 
    if(isRegistered) 
    { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    UserProfileViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"UserProfileVewController"]; 
    [self.navigationController pushViewController:vc animated:YES]; 
    } 
} 

ユーザーが既に登録されているかどうか、UserViewControllerをスキップできますか? UserProfileVewControllerに直接アクセスするには、UserViewControllerではなく、login/signup viewcontrollerです。プロジェクトのAppDelegateで

enter image description here

答えて

1

、ユーザーが/ログイン登録されているかどうか確認して、依存ViewControllersを表示することができます:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Override point for customization after application launch. 

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    BOOL userIsLoggedIn = AMethodCheckIfUserLoggedIn(); 
    if (userIsLoggedIn) { 
     UserProfileViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"UserProfileVewController"]; 
     self.window.rootViewController = vc; 
    } 
    else{ 
     UserViewController *userViewController = [storyboard instantiateViewControllerWithIdentifier:@"UserViewController"]; 
     self.window.rootViewController = userViewController; 
    } 

    //... Other logic goes here 

    [self.window makeKeyAndVisible]; 
    return YES; 
} 
0

あなたはアプリのデリゲート(または誰とあなたを持つ試みることができます本当に欲しい)はUITabBarControllerDelegateに準拠し、- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewControllerを実装します。そこには、おそらくビューコントローラの必要なチェック/手書きをすることができるかもしれません。

関連する問題