简体   繁体   English

控制器之间的导航-黑屏

[英]Navigation between Controllers - Black Screens

I'm trying to work on a simple login application which on successful login displays a menu page. 我正在尝试使用一个简单的登录应用程序,成功登录后将显示一个菜单页面。 On the action sheet of menu page, we have an option of looking at all the users logged in that phone and clicking on any user, it should do some login processing and direct to menu page again. 在菜单页面的操作表上,我们可以选择查看登录该手机的所有用户,然后单击任何用户,它应进行一些登录处理并再次直接进入菜单页面。 This is how the workflow should go on. 这就是工作流程应如何进行。

Below is the image that explains it. 下面是解释它的图像。

在此处输入图片说明

All the controllers are connected to segues except for accounts controller and middle controller. 除帐户控制器和中间控制器外,所有控制器都连接到segue。 Navigation between those two is done using pushViewController as I had to pass some info from accounts controller(table view controller with list of all users) to middle Controller. 这两个之间的导航是使用pushViewController完成的,因为我必须将一些信息从帐户控制器(带有所有用户列表的表视图控制器)传递到中间控制器。

 MiddleController *maController = [[MiddleController alloc] init];
        if (maController.view) {
            maController.ma_userId = mo_userId; // Set the exposed property
            maController.ma_password = mo_password;
        [self.navigationController pushViewController:maController animated:YES];

Middle controller is doing all the process perfectly after getting the details. 获得详细信息后,中间控制器可以完美地完成所有过程。 But directing to menu controller is where I'm facing the problem. 但是,面对菜单控制器是我面临的问题。 If I use a segue between middle controller and menu controller an error is thrown saying no identifier with the name segueName found . 如果我在中间控制器和菜单控制器之间使用segue,则会引发错误no identifier with the name segueName found But if I use a pushViewController then it is displaying a blank black screen. 但是,如果我使用pushViewController它将显示黑屏。 Can some help me to solve this. 可以帮我解决这个问题。

This is how I'm pushing it: 这就是我的推动方式:

 MenuTableViewController *mapMenuTableviewController = [[MenuTableViewController alloc]init];
        [self.navigationController pushViewController:mapMenuTableviewController animated:NO];

I've tried all the ways that are posted in previous SO questions, but nothing helped. 我已经尝试了以前的SO问题中发布的所有方法,但是没有任何帮助。

Thanks in advance 提前致谢

Try not to alloc-init, but instantiate it fom storyboard like this (you should add it a storyboard id) 尽量不要alloc-init,而是像这样在Storyboard上实例化它(您应该为其添加一个Storyboard ID)

YourViewControllerClass *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"];

And then push it. 然后推。

You need to add storyboard id like this 您需要像这样添加情节提要ID

在此处输入图片说明

And use like 并使用像

UIViewController *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewControllerID"];

Go to your storyboard, and set an identifier like this : 转到您的情节提要,并设置如下标识符:

在此处输入图片说明

Now, in your view controller, do this : 现在,在您的视图控制器中,执行以下操作:

YourViewController *viewController = [[UIStoryboard storyboardWithName:@"<your storyboard name>" bundle:nil] instantiateViewControllerWithIdentifier:@"myViewControllerID"];
[self.navigationController pushViewController:viewController animated:NO];

UPDATE - 更新-

Push you Accounts view controller and Middle view controller the way i told before. 以我之前讲过的方式向您推送Accounts视图控制器和Middle视图控制器。

Then, when your processing is done in the middle controller, just do this : 然后,当您在中间控制器中完成处理时,只需执行以下操作:

  [[self presentingViewController]presentingViewController]dismissViewControllerAnimated:NO completion:nil];

Add storyboard Id to yput interface builder "SendSMSViewController" and call below code. 将情节提要ID添加到yput界面构建器“ SendSMSViewController”,然后调用以下代码。

let SendSmsVC = self.storyboard?.instantiateViewControllerWithIdentifier("SendSMSViewController") as! SendSMSViewController

    self.navigationController?.pushViewController(SendSmsVC, animated: true)

Plz use this code you will go to MenuTableViewController. 请使用此代码,您将转到MenuTableViewController。

  for (UIViewController *controller in self.navigationController.viewControllers)
                    {
                        if ([controller isKindOfClass:[MenuTableViewController class]])
                        {
                            [self.navigationController popToViewController:controller animated:YES];

                            break;
                        }
                    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM