【发布时间】:2012-06-27 10:58:12
【问题描述】:
HomeViewController - 视图有 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];
}
AppDelegate:
- (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;
}
【问题讨论】:
-
你不应该从超级视图中删除 self,你为什么要这样做?
-
感谢您的评论。我只需要删除 HomeViewCONtroller 的视图,以便我可以看到 TabBarController 视图。这是正确的做法吗?
标签: iphone ios5 uitabbarcontroller