在xcode中单击后退按钮时加载tabbarcontroller?

时间:2012-10-30 16:50:50

标签: iphone xcode4 uitabbarcontroller

当我点击后退按钮然后我加载一个特定的视图。但是对于那个特定的视图我必须添加一个tabbarController.How我能做到吗??当我尝试添加它时不会被添加..无法理解y ?

 -(IBAction)switchtofirst {
AppViewController *first=[[AppViewController alloc] initWithNibName:@"AppViewController" bundle:nil];  
        Login *second=[[Login alloc]initWithNibName:@"Login" bundle:nil];
        second.title=@"Login";
        NSArray *viewArray=[[NSArray alloc] initWithObjects: first,second,nil];
        tabBarController=[[UITabBarController alloc] init];
        [tabBarController setViewControllers:viewArray animated:NO];
        AppViewController *gp=[AppViewController alloc];
         [gp.view addSubview:tabBarController.view]; 
      [self presentModalViewController:gp animated:NO];
        [gp release];
         }

1 个答案:

答案 0 :(得分:1)

尝试这样的事情:

-(IBAction)switchtofirst {

    AppViewController *first = [[AppViewController alloc] initWithNibName:@"AppViewController" bundle:nil];
    Login *second=[[Login alloc]initWithNibName:@"Login" bundle:nil];
    second.title=@"Login";

    NSArray *viewArray= [NSArray arrayWithObjects:first, second, nil];

    tabBarController=[[UITabBarController alloc] init];
    [tabBarController setViewControllers:viewArray animated:NO];

    [self presentViewController:tabBarController animated:YES completion:nil];
}