Hi I am trying to push a view controller in viewDidLoad
I am using storyboard. In ViewDidLoad, I am checking that user is login and he is created his profile. if user is not logged in or he does not created his profile then pushing the another view controller for login/profile view. The following code does not working.
- (void)viewDidLoad
if(USER_IS_LOGGED_IN)
{
if(USER_PROFILE_COMPLETED)
{
[self sendRequest];
}
else
{
//push profile view
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ProfileViewController *profileViewController = (ProfileViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ProfileView"];
profileViewController.isFromDealView = YES;
profileViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:profileViewController animated:YES];
}
}
else
{
//push login view
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
LoginViewController *loginViewController = (LoginViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LoginView"];
loginViewController.isFromDealView = YES;
loginViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:loginViewController animated:YES];
}
}
I am little confuse with your code but any way try this
- (void)viewDidLoad {
if(USER_IS_LOGGED_IN) {
if(USER_PROFILE_COMPLETED)
{
[self sendRequest];
}
else
{
//push profile view
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ProfileViewController *profileViewController = (ProfileViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ProfileView"];
profileViewController.isFromDealView = YES;
profileViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:profileViewController animated:YES];
}
} else {
//push login view
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
LoginViewController *loginViewController = (LoginViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LoginView"];
loginViewController.isFromDealView = YES;
loginViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:loginViewController animated:YES];
}`
}