您可以首先设置loginViewController作为rootViewControllermain window,然后在用户登录后,将tabBarController 设置为rootViewController.
像这样的东西(假设你的loginViewController是viewController1):
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
UINavigationController *myNav1=[[UINavigationController alloc] initWithRootViewController:viewController1];
UINavigationController *myNav2=[[UINavigationController alloc] initWithRootViewController:viewController2];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:myNav1,myNav2, nil];
//set the login view
self.window.rootViewController = viewController1;
[self.window makeKeyAndVisible];
return YES;
}
-(void)setTabBar{
//self.viewController1=nil;
self.window.rootViewController = self.tabBarController;
}
Run Code Online (Sandbox Code Playgroud)
然后从loginViewController调用appDelegate的方法setTabBar.
LoginViewController.m
#import "AppDelegate.h"
-(void)loginOK{
AppDelegate *del=(AppDelegate*)[[UIApplication sharedApplication] delegate];
[del setTabBar];
//you could add some animation transition between views
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1377 次 |
| 最近记录: |