2013-01-18 39 views
-1

我在這裏有2個場景。 1.使用VC1中的按鈕單擊我想移動到VC6,然後向後滑動。這是通過上面提到的代碼完成的。 2.我也有在VC1滑動手勢移動到VC2,Vc3,VC4,VC5和VC6.Now我想從VC6滑回VC5,Vc4,VC3,VC2,然後到VC1。我可以分別實施這兩種情況。但是我怎麼能一起實現這些場景。如何在使用按鈕時彈出以及在viewController上滑動手勢

我有六個viewControllers。在viewController1我有一個按鈕,帶我到viewController6。我再從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]; 


} 

我也有UISwipeGestureRecognizerviewController1這需要我viewController2viewController3viewController4同時也viewController6彈回至viewController5viewController4viewController3viewController2viewController1分別。當我在viewController1上使用UISwipeGestureRecognizer時,我將如何從viewController6回彈,我也有上面提到的代碼。

+0

什麼時候你想流行? –

+0

當你在vc1中滑動時,你將如何使用vc 6? –

+0

如果你想刪除堆棧中的所有視圖控制器使用彈出到根視圖控制器 –

回答

0

獲取滑動手勢(從右到左)並在其中寫入popViewController的代碼。

+0

嗨piyush,我明白這一點。但我怎麼能實現1.與VC1的按鈕點擊我想移動到VC6,然後向後滑動。這是通過上面提到的代碼完成的。 2.我也有在VC1滑動手勢移動到VC2,Vc3,VC4,VC5和VC6.Now我想從VC6滑回VC5,Vc4,VC3,VC2,然後一起VC1。 – Ankita

相關問題