まず、AccountViewController
に2番目のタブを設定します。その後、ユーザーが署名されている場合、ユーザーがログインしていない場合tabBarController:didSelectViewController:
コールバックで、チェック、LoginViewController
でのViewControllerを置き換える:ユーザーがログインインした後
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if ([tabBarController selectedIndex] == 1 && !user.isSignedIn)
{
//fill an array with all the view controllers in the UITabBarController
NSMutableArray *arr = [[NSMutableArray alloc] initWithArray:[tabBarController viewControllers]];
//inistantiate login view controller
UIViewController *loginViewController = [[LoginViewController] init];
//replace the second UIViewController in the array with LoginViewController
[arr replaceObjectAtIndex:1 withObject: loginViewController];
//set array
[tabBarController setViewControllers:arr];
}
}
を、と2番目のタブを置き換えますAccountViewController