HomeViewController - View 有 2 个图像按钮,分别称为“新”和“旧”。这是我在 TabBarController 启动之前显示的起始视图。
当点击“新建”时,我转到 TabBarItem 1。好的,没问题。*当点击“旧”时,我想转到 TabBarItem 4。 *但它仍然转到 TabBarItem 1。
这就是我的代码的样子:
在 HomeViewController 中,我有以下方法:
- (void) oldButtonPressed:(id)sender{
TabBarAppDelegate *allRootValues = [[UIApplication sharedApplication] delegate];
allRootValues.seeExistingClients = @"Y";
NSLog(@"old button pressed: see old clients: %@", allRootValues.seeExistingClients);
[self.view removeFromSuperview];
[self.tabBarController setSelectedIndex:4];
}
应用委托:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// Override point for customization after application launch.
HomeViewController *homeVC = [[HomeViewController alloc]initWithNibName:@"HomeViewController" bundle:nil];
[self.window addSubview:homeVC.view];
[self.window makeKeyAndVisible];
seeExistingClients = @"N"; //Assigning to 'N' initially
return YES;
}