0

私はセカンドビューにタブを実装しようとしています.Onボタンタッチ(ViewController.mから)私はセカンドビュー(タブ)に移動しています。私のTabs.xibファイルでは、下部に TabBar を追加しました。これは のカスタム クラスですUITabBar

ViewController.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];

上記で定義したようにviewcontrollerのインスタンスを定義し、各viewcontrollerに対して正確なnibファイル名を指定してください。

于 2012-12-06T05:02:17.017 に答える