Let me explain clearly now,
I have a tabbarcontoller in the viewcontroller which is the main view controller of the single view application project.
I added a tabbarcontroller to the viewcontroller as the subview. In the tabbarcontroller, I added two navigation controllers like below image,
I have added three(named First, Second, Third) more viewcontrollers as new file.
If I navigate from one viewcontroller to other in the first tab using below code,
third = [[Third alloc] initWithNibName:@"Third" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:third animated:YES];
Then I switch to second tab by clicking the tab below the tabbarcontroller.
and then
If I switch to next tab(first tab) by clicking a button in third view controller using,
-(IBAction)switchtab
{
vc.tabctrl.selectedIndex=0;
//vc is the main viewcontroller to which the tabbarcontoller(tabctrl) added as subview
}
After switching to next tab, there I should poptorootviewcontroller, I tried below code
-(IBAction)switchtab
{
vc.tabctrl.selectedIndex=0;
[vc.tabctrl.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
}
But it jumps to next tab but popToViewController not working, any suggestions?