0

我在 appdelegate.m 中添加了 UITabBarController。请检查以下代码

 DiViewController *contact  = [[DiViewController alloc] initWithNibName:@"DiViewController" bundle:nil];
    UINavigationController *contactNav =  [[UINavigationController alloc] initWithRootViewController:contact];
    contactNav.navigationBar.barStyle = UIBarStyleBlack;


    self.tabController = [[UITabBarController alloc] init];
    CGRect tabframe = self.tabController.tabBar.frame;
    tabframe.origin.y -= 10;
    tabframe.size.height += 10;
    self.tabController.tabBar.frame = tabframe;
    self.tabController.delegate = self;
    self.tabController.viewControllers = @[contactNav];

然后我在打开的模拟器底部标签栏中运行 DiViewController.xib。然后我点击了在 appdeletgate.m 中工作的 tabbar item.didSelectViewController。但我想在 DiViewController.m 中。我可以在 DiViewController.m 中获取 didSelectViewController。我在 DiViewController.m 中使用了相同的方法,但没有工作。

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{



}
4

0 回答 0