0

我有3个ViewController,流程:rootviewcontroller是view1,当我点击view1中的“开始”按钮时,它会推动view2,然后点击view2中的“状态”按钮,它会推动view3。在 view3 中有 uitabbarcontroller 和里面 tabbarcontroller 有 2 UINavigationController 。我的问题是:当单击 tabbarcontroller 中 UINavigationController 中的“注销”按钮时,我回调 view2。但是当view2出现时,我点击“状态”按钮,它无法推送view3。创建的 UItabbarcontroller 的代码

self.tab=[[UITabBarController alloc]init];
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568)
{
    // code for 4-inch screen
    //  LoginButton.frame = CGRectMake(0, 518, 80, 49);
    self.tab.view.frame = CGRectMake(0,0,320,568);
}
else if (screenBounds.size.height == 1024)
{
    //code for ipad

}
else  if (screenBounds.size.height == 480)
{
    // code for 3.5-inch screen
    //  LoginButton.frame = CGRectMake(0, 430, 80, 49);
    self.tab.view.frame = CGRectMake(0,0,320,480);
}

// FirstViewController
UploadTab *uploadview=[[UploadTab alloc]initWithNibName:nil bundle:nil];
UINavigationController *uploadTabItem = [[[UINavigationController alloc] initWithRootViewController: uploadview] autorelease];
uploadview.title=@"Uploading";
uploadview.tabBarItem.image=[UIImage imageNamed:@"Uploading.png"];
self.title = @"FirstViewControllerTitle";

//SecondViewController
ConvertTab *convertView=[[ConvertTab alloc]initWithNibName:nil bundle:nil];
UINavigationController *convertTabItem = [[[UINavigationController alloc] initWithRootViewController: convertView] autorelease];
convertView.title=@"Convert";
convertView.tabBarItem.image=[UIImage imageNamed:@"Convert.png"];

//ThirdViewController
CompletedTab *completedView=[[CompletedTab alloc]initWithNibName:nil bundle:nil];
UINavigationController *completedTabItem = [[[UINavigationController alloc] initWithRootViewController: completedView] autorelease];
completedView.title=@"Completed";
completedView.tabBarItem.image=[UIImage imageNamed:@"Completed.png"];
UIBarButtonItem * LogoutItem= [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Logout.png"] style:UIBarButtonItemStylePlain target:self action:@selector(logout)];

self.navigationItem.rightBarButtonItem = LogoutItem;
self.tab.viewControllers=[NSArray arrayWithObjects:uploadTabItem,convertTabItem, completedTabItem, nil];

[self.view insertSubview:self.tab.view belowSubview: uploadview.view];
[self presentModalViewController:self.tab animated:NO];

我使用下面的代码来回调 view2:

    - (void) handleBack:(id)sender
{
    ChooseViewController *chooseview = [[ChooseViewController alloc] init];
    [self.navigationController pushViewController:chooseview animated:NO];
    [chooseview release];

}

我用过[self.navigationController presentModalViewController:loginView animated:YES]; 。我认为它使 view2 无法推送 view3。你有什么建议吗 ?非常感谢

4

1 回答 1

0

希望这可能有用:

NSArray *viewControllers = [[self navigationController] viewControllers];  
    for (int i = 0; i < [viewContrlls count]; i++){  
        id obj = [viewControllers objectAtIndex:i];  
        if ([obj isKindOfClass:[yourViewControllername class]]){  
            [[self navigationController] popToViewController:obj animated:YES];  
            return;
        }
    }    

使用它,您可以返回到任何特定视图。

于 2013-08-09T18:33:40.427 回答