简体   繁体   English

在同一个类的两个视图控制器之间导航?

[英]Navigating between two view controller of the same class?

In my project, I am having a navigation controller.In one of the view controller class I am having two views.One is actually created when I added the class and another is added manually by myself.So both the views having same class. 在我的项目中,我有一个导航控制器。在一个视图控制器类中,我有两个视图。一个视图实际上是在我添加该类时创建的,另一个是我自己手动添加的,所以两个视图都具有相同的类。

My problem is when I want to navigate from one of those views to another.Its navigation fine for me.But when I come back and again go to the view, app getting crash with error message "'Pushing the same view controller instance more than once is not supported ()' " 我的问题是,当我想从这些视图之一导航到另一个视图时,它的导航对我来说很好。但是当我再次返回视图时,应用程序崩溃,并显示错误消息“'将相同的视图控制器实例推到更多不支持一次()'“

Please remember I am tring to navigate between the views of same class. 请记住,我正试图在同一个类的视图之间导航。

Navigating code is, 导航代码是

[self.navigationController pushViewController:viewController1 animated:YES];

What would be my problem? 我怎么了

Please share your ideas. 请分享您的想法。

This is the code I used 这是我使用的代码

- ( IBAction ) askForPaymentType:(id)sender {

  [self.navigationController pushViewController:viewPaypal animated:NO];
    NSLog(@"%@",[self.navigationController viewControllers]);

}

Just use the addSubview method. 只需使用addSubview方法。 Take another view in xib of same class and add the view on main view. 在同一个类的xib中获取另一个视图,并将该视图添加到主视图中。 After you finished just removeFromSuperview and clear its memory. 完成后,只需removeFromSuperview并清除其内存。

- ( IBAction ) askForPaymentType:(id)sender {
[self.view addSubview:viewPaypal];
}

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

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