2013年3月5日 星期二

加入登入畫面的方法

In your AppDelegate, at the end of the application didFinishLaunchingWithOptions method you'll see this:
[window addSubview:tabcontroller.view];
[window makeKeyAndVisible];
return YES;

Simply initialize your login view controller and add it after the tabcontroller, like this: initialScreenViewController = [[InitialScreenViewController alloc] init];
self.window.rootViewController = self.tabBarController;
//[self.window addSubview:self.tabBarController.view];
//[self.window addSubview:viewController1.view];
[self.window makeKeyAndVisible];
[self.tabBarController presentViewController:viewController1 animated:NO completion:^{ ; }];
return YES;

In you login viewcontroller, after authenticating the user you can hide it like this:

AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[delegate.tabBarController dismissViewControllerAnimated:YES completion:^{ ; }];

which allows you to show it again if you have a logout feature.

沒有留言:

張貼留言