简体   繁体   中英

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. Take another view in xib of same class and add the view on main view. After you finished just removeFromSuperview and clear its memory.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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