I am encountering a very strange problem.
Here is the code structure in my app delegate:
self.accountViewController = [[AccountViewController alloc] initWithNibName:@"AccountViewController" bundle:nil];
self.homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
self.exploreViewController = [[ExploreViewController alloc] initWithNibName:@"ExploreViewController" bundle:nil];
self.activityViewController = [[ActivityViewController alloc] initWithNibName:@"ActivityViewController" bundle:nil];
self.homeNavigationController = [[UINavigationController alloc] initWithRootViewController:self.homeViewController];
self.accountNavigationController = [[UINavigationController alloc] initWithRootViewController:self.accountViewController];
self.activityNavigationController = [[UINavigationController alloc] initWithRootViewController:self.activityViewController];
self.exploreNavigationController = [[UINavigationController alloc] initWithRootViewController:self.exploreViewController];
self.tabBarController = [[MyOwnTabBarController alloc] init];
[self.tabBarController setDelegate:self];
[self.tabBarController setViewControllers:[NSArray arrayWithObjects:self.homeNavigationController, self.exploreNavigationController,self.activityNavigationController,self.accountNavigationController,nil]];
[self.tabBarController setSelectedIndex:0];
[self.navController setViewControllers:[NSArray arrayWithObjects:self.welcomeViewController, self.tabBarController, nil] animated:NO];
for that self.navController, I define that like this
self.navController = [[UINavigationController alloc] initWithRootViewController:self.welcomeViewController];
self.window.rootViewController = self.navController;
so after the tabbarcontroller is presented, i will be at the homeviewcontroller where i have a collectionview. it successfully display multiple cell. When I click on the cell,
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[self.navigationController pushViewController:vc animated:YES];
}
i see that the navigation bar is changed with the new title in "vc", and the navigation bar's back button also show up. However, the view is not changed, i am still able to access the collectionview.
however, if i pressed on other tab on the tabbarcontroller such as the accountviewcontroller,and then press back to the old tab for homeviewcontroller again, the view will now show up. this is a very weird behavior that i have no idea why it happens.
i also checked that in each of the view controller, the self.navigationcontroller is not nil