0

当我单击后退按钮时,我正在加载一个特定的视图。但是对于那个特定的视图,我必须添加一个 tabbarController。我该怎么做..?当我尝试添加它时,它没有被添加..无法理解 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];
         }
4

1 回答 1

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];
}
于 2012-10-30T18:01:30.910 回答