如何从CustomViewController中更改RootViewController(在AppDelegate中)? [英] How to change RootViewController (in AppDelegate) from within CustomViewController?

查看:291
本文介绍了如何从CustomViewController中更改RootViewController(在AppDelegate中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,

我的应用程式已经在AppDelegate中加载了授权表单(SigninController),登录后(CheckinController.m中检查)TabBarController应该出现(作为应用程序的主要视图)。

My app has authorization form (SigninController) which is loaded in AppDelegate, and after signing in (checking is in SigninController.m) TabBarController should appear (as main view of application).

如何将控制器从Signin更改为TabBar,哪里?

How can I change controller from Signin to TabBar and where ??

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {  
SigninController *aSigninController = [[SigninController alloc] initWithNibName:@"SigninView" bundle:nil];
self.currentController = aSigninController;
[aSigninController release];

self.window.rootViewController = self.currentController;
[self.window makeKeyAndVisible];
return YES;
}

SigninController.m

SigninController.m

- (IBAction)signinClick
{
........
if (loginOK == YES)
{        
      //This place is ready to send messages to show TabBar
} else {
    UIAlertView *alert = ......
    [alert show];
    [alert release];
}    
}


推荐答案

[appDelegate.window addSubview:appDelegate.tabbarController.view];

[self.view removeFromSuperview];

appDelegate是应用程序共享委托。

appDelegate is the application shared delegate.

MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];

这篇关于如何从CustomViewController中更改RootViewController(在AppDelegate中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆