popToViewControllerメソッドを使用してViewControllerにポップしています。私が達成しようとしていたのは、UITabBarControllerの特定のインデックスにポップすることです。
NSArray *viewArrays = [self.navigationController viewControllers];
つまり、私のビュー階層は次のとおりです。
<LoginViewController: 0x6b75850>,
<UITabBarController: 0x6ba0b50>,
<RequestViewController: 0x684fe90>,
<ApplyViewController: 0x6845790>
次のコードはUITabBarControllerにポップしますが、UITabBarControllerの3番目のビューにいたため、3番目のビューにポップバックします。
[[self navigationController] popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
私が欲しいのは、UITabBarControllerの2番目のビューにポップすることです。
編集(回答)
述べたように、私たちはプッシュしたりポップしたりしません。したがって、tabBarControllerを収集するには、次のいずれかを使用します。
UITabBarController *myTabController = [self.navigationController.viewControllers objectAtIndex:indexOfYourTabBarControllerInYourNavigationController];
myTabController.selectedIndex = indexToGo;
または、tabBarControllerビューの1つを使用している場合。
self.tabBarController.selectedIndex = indexToGo;