2012-01-25 3 views
2

ViewControllerA and ViewControllerBという名前の2つのUIViewControllerがあります。 ViewControllerAは親クラスであり、ViewControllerBは子クラスであり、ViewControllerAクラスからの[self.navigationController pushViewController:viewControllerB animated:YES];によって表示されます。 ViewControllerBクラスで私はNavigationBarを隠しました。ボタンアクションでは、ViewControllerBからViewControllerAに来るようにコードされました。[self.navigationController popViewControllerAnimated:YES];。今、私はUIButtonを使用するのではなく、スワップアクション(前の画面にスクロール)を使用してViewControllerBからViewControllerAを取得したいと思います。これどうやってするの?誰でも私に提案やアイデアを提供してもらえますか?前もって感謝します。スクロールアクションを使用して、child viewcontrollerからparent viewcontrollerを取得する方法は?

答えて

2

使用したいとこの子のコントローラで

- (void)viewDidLoad 
{  
    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; 
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionUp)]; 
    [[self view] addGestureRecognizer:recognizer]; 
    [recognizer release]; 
    [super viewDidLoad]; 
} 

-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer 
{ 
    [self.navigationController popViewControllerAnimated:YES]; 
    NSLog(@"Swipe received."); 
} 

使用方向..

ハッピーコーディング...偉大な答えを

+0

偉大な答えをありがとう。私は私の問題を解決しました。 –

2

[self.navigationController popViewControllerAnimated:YES];のハンドラーメソッドを使用して、子ビューでUISwipeGestureRecognizerを使用できます。

+0

感謝。私は私の問題を解決しました。 –

関連する問題