2015-01-02 86 views
-1

我目前正試圖通過向左滑動來連接不同的ViewControllers,但是,我的代碼不適合我。我加輕掃手勢識別到ViewController在stroyboard文件 這是我的代碼在ViewController與故事板之間滑動

UISwipeGestureRecognizer *swipeLeftGesture=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)]; 
[self.view addGestureRecognizer:swipeLeftGesture]; 
swipeLeftGesture.direction=UISwipeGestureRecognizerDirectionLeft; 


     } 

-(void)handleSwipeGesture:(UIGestureRecognizer *) sender 
{ 
NSUInteger touches = sender.numberOfTouches; 
if (touches == 2) 
{ 
    if (sender.state == UIGestureRecognizerStateEnded) 
    { 
     //Add view controller here 
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone6" bundle:nil]; 
     UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; 
     [self presentViewController:vc animated:YES completion:nil]; 
     } 
    } 
} 

回答

2

雖然可以手動做到這一點,很多人都內置工具來幫助你做到這一點。我建議RKSwipeBetweenViewControllers。易於安裝,易於使用。

沒有更多關於UISwipeBetweenViewControllers的想法!

+0

感謝您的幫助! – user1569766

+0

當然!祝你好運!如果你能夠讓我的答案被接受,那麼它會很棒。 –

+1

我需要15點聲望 – user1569766