ここに2つのシナリオがあります。1. VC1 からボタンをクリックして VC6 に移動し、スワイプして戻りたい。これは、上記のコードによって行われます。2. また、VC1 で VC2、VC3、VC4、VC5、および VC6 に移動するためのスワイプ ジェスチャがあります。これら 2 つのシナリオを個別に実装できます。しかし、どうすればこれらのシナリオを一緒に実装できますか?
私は6つのviewControllerを持っています。に移動viewController1
するボタンがありますviewController6
。そして、コードを使用してviewController5
、viewController4
、viewController3
、viewController2
およびviewController1
それぞれにポップバックしますviewController6
- (IBAction)SwipeGoto5:(UISwipeGestureRecognizer *)sender
{
IndexPage *P1VC=[[IndexPage alloc] initWithNibName:@"IndexPage" bundle:nil];
Page2 *P2VC=[[Page2 alloc] initWithNibName:@"Page2" bundle:nil];
Page3 *P3VC=[[Page3 alloc] initWithNibName:@"Page3" bundle:nil];
Page4 *P4VC=[[Page4 alloc] initWithNibName:@"Page4" bundle:nil];
Page5 *P5VC=[[Page5 alloc] initWithNibName:@"Page5" bundle:nil];
NSLog(@"swipe to 5");
NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
[allViewControllers insertObject:P1VC atIndex:1];
[allViewControllers insertObject:P2VC atIndex:2];
[allViewControllers insertObject:P3VC atIndex:3];
[allViewControllers insertObject:P4VC atIndex:4];
[allViewControllers insertObject:P5VC atIndex:5];
self.navigationController.viewControllers=allViewControllers;
[self.navigationController popViewControllerAnimated:YES];
}
私はまた、私をに連れて行ってくれるUISwipeGestureRecognizer
上に持っています。onを使用し、上記のコードも持っているときにどのようにポップバックしますか。viewController1
viewController2
viewController3
viewController4
viewController6
viewController6
UISwipeGestureRecognizer
viewController1