My app has four tabs that displays different information.
In my second tab view controller i have one button lets name it as button1
in that button1
action i have navigated to SignInViewController
screen and in my third tab view controller is loginViewController
.
Here purpose of both SignInViewController
and loginViewController
screen is same i.e.,user can logged into the app in both the ViewController's.
Here what i want exactly is, if I am logged in SignInViewController
then whenever I tap on third TabBarItem
View Controller should directly navigated to next screen of loginViewController
i.e.,to that next screen i have named it as AccountViewController
. I have tried below code in tabbarcontroller
class but its does not working.
Please help me on this. Thanks in Advance.
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (tabBarController.selectedIndex == 2){
{
if (![[[NSUserDefaults standardUserDefaults]objectForKey:@"SigninStatus"] isEqualToString:@"SigninSuccess"]){
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
LoginViewController *logInVc = [story instantiateViewControllerWithIdentifier:@"LoginViewController"];
[self.navigationController pushViewController:logInVc animated:YES];
}
else
{
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
AccountViewController *accountVc = [story instantiateViewControllerWithIdentifier:@"AccountViewController"];
[self.navigationController pushViewController:accountVc animated:YES];
}
}
}
}