简体   繁体   English

当我打电话给下一个视图控制器时出错

[英]error when i am calling next view controller

i am getting an error when i am calling next view controller, i want to call a view controller that a action continue .this screen will come appear first time only when we run first time. 我在调用下一个视图控制器时遇到错误,我想调用一个动作继续的视图控制器。只有当我们第一次运行时,此屏幕才会第一次出现。 controller is not going next view. 控制器不会进入下一个视图。

-(void)viewDidLoad
{
    welcomePage *temp = [[welcomePage alloc]initWithNibName:@"welcomePage" bundle:nil];       
    [self presentViewController:temp animated:YES completion:^(void){}];

}

Warning: Attempt to present on whose view is not in the window hierarchy! 警告:尝试显示不在窗口层次结构中的视图!

use this code 使用此代码

-(void)viewDidLoad
{
    welcomePage *temp = [[welcomePage alloc]initWithNibName:@"welcomePage" bundle:nil];       
    [self presentViewController:temp animated:YES completion:nil];
}

If You are using Storyboard : Use this 如果您使用的是Storyboard:请使用此

instantiateViewControllerWithIdentifier InstantiateViewControllerWithIdentifier

    UIViewController objController  = [self.storyboard instantiateViewControllerWithIdentifier:@"StoryBoard Id"];
 [self presentViewController:objController animated:YES completion:nil];

To Set Storybaord ID , Check Here . 要设置Storybaord ID, 请在此处检查

该错误意味着您正在尝试从当前不在屏幕中的视图控制器中呈现模式视图控制器。

This error means that you are trying to present 'welcome page' from a view that is not on the screen yet. 此错误表示您正在尝试从屏幕上尚未显示的视图中显示“欢迎页面”。

Knowing that simply moving the code to the viewDidAppear method doesn't work for you, what you can try to do is this: 知道仅将代码移到viewDidAppear方法对您不起作用,您可以尝试执行以下操作:

-(void)viewDidAppear
{
    [self presentWelcome];
}

- presentWelcome {
welcomePage *temp = [[welcomePage alloc]initWithNibName:@"welcomePage" bundle:nil];       
    [self presentViewController:temp animated:YES completion:^(void){}];
}

What happens here is that when the view appears (so when it is in the view hierarchy), the controller starts a function that calls the other viewController. 这里发生的是,当视图出现时(因此,当它处于视图层次结构中时),控制器启动了一个函数,该函数调用另一个viewController。 hope this solves your problem. 希望这能解决您的问题。

Hope this helps you! 希望这对您有所帮助!

Try this one.. 试试这个

You change the code in Appdelegate.m didFinishLaunchingWithOptions method like this 您可以像这样更改Appdelegate.m didFinishLaunchingWithOptions方法中的代码

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:self.viewController];
self.window.rootViewController = nav;

And in your ViewDidLoad method like this.. 在这样的ViewDidLoad方法中。

welcomePage *temp = [[welcomePage alloc]initWithNibName:@"welcomePage" bundle:nil];       
[self.navigationController presentViewController:temp animated:YES completion:nil];

For dismissing viewcontroller you can write following code in welcomepage button action 要关闭视图控制器,您可以在welcomepage按钮操作中编写以下代码

-(IBAction)dismiss:(id)sender{
[self dismissViewControllerAnimated:YES completion:nil];
}

暂无
暂无

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

相关问题 启动应用程序时未出现下一个视图控制器 - next view controller is not appearing when i launched apps 当我在tabBar中的视图控制器中时如何访问navigationItem? - How to access to navigationItem when I am in a view controller in tabBar? 当我使用导航 controller 时视图消失时出现黑条 - black bar as the view fades when I am using navigation controller 您好,我正在使用 Collection View 单元格,我想记录其中有多少被点击“变为真”并返回下一个视图 controller - Hello I am using a Collection View cell and I want to record how many of them are clicked “made true” and return on the next view controller 执行segue时未加载下一个视图控制器 - next view controller is not loaded when the segue is performed 当我单击视图控制器中显示的列表标签中的特定标签时,将标签文本粘贴到下一个视图 - Pare the label text to next View when i clicked that Particular label from list label showed in view controller iPhone-当视图映射正确时,为什么会出现此错误? - iPhone - Why am I getting this error when the view mapping is correct? 错误:当我从Swift中的不同类调用函数时,调用中的参数#1缺少参数 - Error: Missing argument for parameter #1 in call when I am calling a function from different class in Swift 视图控制器调用模式视图 - View controller calling a modal view 从Segue加载视图控制器时调用特定的构造函数 - Calling specific constructor when loading a view controller from segue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM