1

我有一个应用程序,其中有一个activationView. 激活应用程序后,我需要在选项卡中显示其余视图。我用谷歌搜索并发现要在 iPhone 中使用选项卡,该应用程序必须是Tab Bar Application我的应用程序不符合我的要求的应用程序。实现选项卡的最佳方法是什么(在应用程序中的第二个视图上)?

编辑 1

我尝试过的代码

/*  tabsController = [[Tabs alloc] init];
        [self.window setRootViewController:tabsController];*/

        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; appDelegate.window.rootViewController = tabsController;

我已经尝试了这些方法,但我得到了一个纯白色的视图。

4

3 回答 3

2

当您从第一个视图移动到标签栏视图时,请尝试下面的代码。

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; appDelegate.window.rootViewController = yourTabbarController;

于 2012-11-30T07:16:36.200 回答
1

我想你可能会在一个项目中寻找多个 VC。因此,在 appDelegate 中为 loginVC 和其他 VC(用于 tabbar)声明并初始化一个 VC,登录成功后调用以下函数。

在启动时将 LoginVC 设为 RootViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{// declare LoginVC and make it rootViewController
 self.window.rootViewController = self._loginVCObj;
    [self.window makeKeyAndVisible];
}

#pragma mark- Continue to next screen after successful Login

-(void) continueToNextView
{   // Handle UI after Login like.
 [_loginVCObj._indicator stopAnimating];
    [_loginVCObj._loginButton setEnabled:YES];
//add the VC to the tabbar 
    self._tabBarController.viewControllers = [NSArray arrayWithObjects:self.navigationControllerList,_favItemListNavObj, _toDoHereVC, _settingNavObj, nil]; 
// make tabbar as rootViewController
     self.window.rootViewController = self._tabBarController;
}
于 2012-11-30T07:31:57.617 回答
1

我认为您的代码在“基于窗口的应用程序”中工作,但是使用新的 SDK,您不能新建这样的项目。

如果您想使用您的代码,这将对您有所帮助: 在 XCode 上找不到基于窗口的应用程序

如果您使用故事板,那么构建这样的应用程序非常容易。

于 2012-11-30T08:16:55.937 回答