iOS – uitabbarcontroller之前的login视图

我想在login成功时显示接口UITabBar 。 我在AppDelegate声明了接口UITabBar ,但是在login成功之后,我不知道如何调用接口。

这是我的代码:

appdelegate.m

  -(void)loadInterface { [self configureiPhoneTabBar]; } -(void)configureiPhoneTabBar { UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; UIViewController *controller1 = [[tabBarController viewControllers] objectAtIndex:0]; [self configureTabBarItemWithImageName:@"home_ON.png" : @"home.png" andText:@"Trang chủ" forViewController:controller1]; UIViewController *controller2 = [[tabBarController viewControllers] objectAtIndex:1]; [self configureTabBarItemWithImageName:@"channel_ON.png" : @"tvChannel.png" andText:@"Kênh" forViewController:controller2]; } 

loginviewcontroller.m

 - (IBAction)btnLogin:(id)sender { [self performSegueWithIdentifier:@"idenLogin" sender:self]; AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [delegate loadInterface]; } 

其次,当你点击button“播放”,布局video显示,它工作正常,但我想自动旋转

注意:这是iPhone上的界面,我修复肖像总结,我仍然显示风景,如何做?

你可以下载我的代码演示在这里

在几个字你需要login屏幕的模态视图。

这是我做的(从应用程序委托类)。 请注意,我有我的login视图devise在故事板。

 - (void) showLoginView { assert(loginController == nil); assert(activityView == nil); UITabBarController *tabbar = (UITabBarController *)self.window.rootViewController; loginController = [tabbar.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"]; loginController.delegate = self; [tabbar presentModalViewController:loginController animated:YES]; } 

我在我的AppDelegate中创build了一个名为WindowState或类似的对象,它pipe理着什么应该是窗口的rootViewController。 最初,这将是一个login或飞溅,然后你可以在你的WindowState类中运行检查,并听取通知,例如。 MyAppDidSignInNotification然后改变你的应用程序的rootViewController到UITabBarController或任何有。

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.windowState = [[FASWindowState alloc] initWithWindow:self.window]; [self.window makeKeyAndVisible]; return YES; }