-1

ここに2つのシナリオがあります。1. VC1 からボタンをクリックして VC6 に移動し、スワイプして戻りたい。これは、上記のコードによって行われます。2. また、VC1 で VC2、VC3、VC4、VC5、および VC6 に移動するためのスワイプ ジェスチャがあります。これら 2 つのシナリオを個別に実装できます。しかし、どうすればこれらのシナリオを一緒に実装できますか?

私は6つのviewControllerを持っています。に移動viewController1するボタンがありますviewController6。そして、コードを使用してviewController5viewController4viewController3viewController2および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を使用し、上記のコードも持っているときにどのようにポップバックしますか。viewController1viewController2viewController3viewController4viewController6viewController6UISwipeGestureRecognizerviewController1

4

1 に答える 1

0

スワイプジェスチャ(右から左)を取得し、そこに popViewController のコードを記述します。

于 2013-01-18T12:14:22.370 に答える