2017-03-02 7 views
-1

私はユーザーがログインをスキップできるアプリを持っています。その中には、ユーザがログインしている場合にViewControllerの1つがユーザプロファイルを表示するuitabbarコントローラがあります。ただし、ユーザがログインをスキップした場合、プロファイルタブをクリックするとログイン画面が表示されます。どうすればこれを実現できますか?事前tabcontroller内のviewcontrollerを条件に従って変更します。

答えて

0

おかげでcodeの下で試してみてください、あなたの必要性に従ってBOOL variableを設定します。詳細はこちらあなたを参照するThis link

BOOL isLogin; 
NSMutableArray *tbViewControllers = [NSMutableArray arrayWithArray:[self.tabBarController viewControllers]]; 

UIViewController *message = [[MessageViewController alloc] initWithNibName:@"MessageViewController" bundle:nil] ; 
[tbViewControllers addObject:message]; 
if(isLogin){ 
    UIViewController *profile = [[ProfileVC alloc] initWithNibName:@"ProfileVC" bundle:nil] ; 
    [tbViewControllers addObject:profile]; 
}else{ 
    UIViewController *LoginVC = [[LoginVC alloc] initWithNibName:@"LoginVC" bundle:nil] ; 
    [tbViewControllers addObject:LoginVC]; 
} 


UIViewController *more = [[[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil] autorelease]; 
[tbViewControllers addObject:more]; 

[self.tabBarController setViewControllers:tbViewControllers]; 
関連する問題