0

我正在尝试将 Tabs 实现到我的 secondView.On 按钮触摸(来自 ViewController.m)中,我正在导航到 secondView(Tabs)。在我的Tabs.xib文件中,我在底部添加了一个 TabBar,它是UITabBar.

视图控制器.m

- (IBAction)touchedInside:(id)sender {
    NSLog(@"touhced up inside");

    Tabs *temp = [[Tabs alloc]initWithNibName:@"Tabs" bundle:nil];
    [self.navigationController pushViewController:temp animated:YES];
    [self presentViewController:temp animated:YES completion:nil];


}

制表符.m

- (void)viewDidLoad
{
    [super viewDidLoad];

     AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UITabBarController *tabBarController = [[UITabBarController alloc]init];
   /* 
    Tab_1 *firstView = [[Tab_1 alloc] init];
    UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"First" image:nil tag:1];
    [firstView setTabBarItem:item1];
    NSLog(@"after first tab is added");
    Tab_2 *secondView = [[Tab_2 alloc] init];
    UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"Sec" image:nil tag:1] ;
    [secondView setTabBarItem:item2];
     NSLog(@"after second tab is added");
    [tabBarController setViewControllers:[NSArray arrayWithObjects:firstView,secondView,nil] animated:NO];
     NSLog(@"after tab is added");
    [appDelegate.window  addSubview:tabBarController.view];
    NSLog(@"after view is added");
   */
    appDelegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIViewController *viewController1 = [[Tab_1 alloc] initWithNibName:@"Tab 1" bundle:nil];
    UIViewController *viewController2 = [[Tab_2 alloc] initWithNibName:@"Tab 2" bundle:nil];
    UIViewController *viewController3 = [[Tab_2 alloc] initWithNibName:@"Tab 1" bundle:nil];

    tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil];
    appDelegate.window.rootViewController = self.tabBarController;
    [appDelegate.window makeKeyAndVisible];
    Tabs *temp = [[Tabs alloc]initWithNibName:@"Tabs" bundle:nil];
    [self.navigationController presentModalViewController:temp animated:NO];

}

错误

Unbalanced calls to begin/end appearance transitions for <ViewController: 0x6833c80>.
2012-12-06 09:57:48.963 demoTabs[667:f803] Unbalanced calls to begin/end appearance transitions for <Tabs: 0x6a3fc90>.
4

1 回答 1

0
Tab_1 *viewController1 = [[Tab_1 alloc] initWithNibName:@"Tab 1" bundle:nil];
Tab_2 *viewController2 = [[Tab_2 alloc] initWithNibName:@"Tab 2" bundle:nil];
Tab_2 *viewController3 = [[Tab_2 alloc] initWithNibName:@"Tab 1" bundle:nil];

按照上面定义的方式定义视图控制器的实例,还要确保为每个视图控制器提供 coorect nib 文件名。

于 2012-12-06T05:02:17.017 回答