0

我有三個觀點,添加多個swipeGestures不工作

View1 <-- View2 --> View3 

現在視圖2上leftSWipeGesture會送我去VIEW3而在右手勢發送到VIEW1

我的問題是,LeftGesture工作正常但不是正確的姿態。我使用兩個

推Segue公司這裏是我的代碼

- (void) screenSwiped 
{ 
    [self performSegueWithIdentifier:@"tourSegue1" sender:self]; 

} 

- (void) screenSwipedRight 
{ 
    [self performSegueWithIdentifier:@"tourSegue2" sender:self]; 

} 


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad 
{ 
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwiped)]; 
swipeLeft.numberOfTouchesRequired = 1; 
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft; 
    [self.view addGestureRecognizer:swipeLeft]; 



UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwipedRight)]; 
swipeRight.numberOfTouchesRequired = 1; 
swipeRight.direction = UISwipeGestureRecognizerDirectionRight; 
[self.view addGestureRecognizer:swipeRight]; 


    [super viewDidLoad]; 

} 

回答

1

你目前在你的崗位開始時的視圖結構是有些誤導。從這個小圖看來,你已經在視圖2中,如果你在導航控制器中,那麼視圖1應該是一個「popViewController」。

所以首先 - 請驗證此信息,並確保您不需要「popViewController」而不是執行WithSequeIdentifier(因爲它不會像這樣倒退)。

+0

看,我使用SwipeGestureRecognize UI從View1到View2。沒有導航。我唯一回到視圖1的方法是轉到視圖3,然後從視圖3調用函數返回到視圖1。但我甚至無法前往View3。如果你有更好的解決方法,請告訴我 –

+0

你能告訴我怎麼做popviewcontroller。再次我沒有做navigationController –

+0

[self.navigationController popViewControllerAnimated:YES];但是,如果你使用的是導航控制器。如果您使用的是seques,那麼無論您使用的是navigationController,無論是在代碼中定義還是使用Storyboard,都可能更有可能。 – Brayden