0

跟随故事板

问题:我有一个 tabViewController,其中包括四个选项卡,第一个选项卡是 homeViewController ,其中包括 sideMenuViewController。现在我想在 tabViewController 之前添加 loginViewController,这只是一次登录。当前。我的应用程序在没有 loginViewController 的情况下正常工作,以下是AppDelegate.m 类中的以下代码。

Now I want to include loginViewController before the tabViewController

请建议我在我的 AppDelegate.m 中进行必要的更改

AppDelegate.m

 (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
tabBarController = (UITabBarController *) self.window.rootViewController;
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];


        MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)tabBarController.viewControllers [0];
        NSParameterAssert ([container isKindOfClass: [MFSideMenuContainerViewController class]]);
    //    UIViewController *historycontr=(UIViewController *)tabBarController.viewControllers[2];
    //    UIViewController *hist=[storyboard instantiateViewControllerWithIdentifier:@"historyController"];
        UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"navigationController"];
        UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
        UIViewController *rightSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"rightSideMenuViewController"];

        [container setLeftMenuViewController:leftSideMenuViewController];
        [container setRightMenuViewController:rightSideMenuViewController];
        [container setCenterViewController:navigationController];



        return YES;
    }
4

1 回答 1

0

拉上一个新的 UIViewController,它将作为 MainStoryboard 上的登录视图控制器。在属性检查器中将标识符更改为 LoginViewController (或适当的东西)

- (void)viewDidAppear:(BOOL)animated
{
     [super viewDidAppear:animated];

      UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
      UIViewController *login = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
      [vc setModalPresentationStyle:UIModalPresentationFullScreen];

      [self presentModalViewController:login animated:YES];
}

成功登录后只需关闭 LoginViewController

检查这个例子

于 2013-08-13T11:17:53.457 回答