iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 当tabBar点击时转到rootView大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我使用了基于视图的app&在那我以编程方式生成TabBar. 问题是: 我有一个Iphone应用程序,其中我有2个tabitems与tabbarcontroller.Inside tabbarcontroller每个viewcontroller是一个导航控制器.当选择第二个选项卡我有一个视图控制器.当选择一个按钮,我正在推动另一个视图控制器到self.navigation controller.并
我使用了基于视图的app&在那我以编程方式生成TabBar.
问题是:

我有一个Iphone应用程序,其中我有2个tabitems与tabbarcontroller.Inside tabbarcontroller每个viewcontroller是一个导航控制器.当选择第二个选项卡我有一个视图控制器.当选择一个按钮,我正在推动另一个视图控制器到self.navigation controller.并且在那个viewcontroller中我正在推动并且去那样.但是问题是当我再次选择tabitem时,pushviewcotrooller会显示在那里.但是当我选择选项卡时,我再次需要rootview

我在AppDelegate.m中的代码是:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

 UINavigationController *nc1;
    nc1 = [[UINavigationController alloc] init];

UIViewController *viewController1 = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    nc1.viewControllers = [NSArray arrayWithObjects:viewController1,nil];





    UINavigationController *nc2;
    nc2 = [[UINavigationController alloc] init];

 UIViewController *viewController2 = [[[secondview alloc] initWithNibName:@"secondview" bundle:nil] autorelease];
    nc2.viewControllers = [NSArray arrayWithObjects:viewController2,nil];


    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
   self.tabBarController.viewControllers = [NSArray arrayWithObjects:nc1,nc2,nil];
  self.window.rootViewController=self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}

解决方法

也许你正在寻找这个:

- (void)tabBarController:(UITabBarController *)tabBarController didSELEctViewController:(UIViewController *)viewController
{       
    int tabitem = tabBarController.SELEctedIndex;
    [[tabBarController.viewControllers objectATindex:tabitem] popToRootViewControllerAnimated:YES];
}

大佬总结

以上是大佬教程为你收集整理的iphone – 当tabBar点击时转到rootView全部内容,希望文章能够帮你解决iphone – 当tabBar点击时转到rootView所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。