2

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

4

2 に答える 2

2

UISwipeGestureRecognizerを実行するハンドラーメソッドを使用して、子ビューで使用を試みることができます[self.navigationController popViewControllerAnimated:YES];

于 2012-01-25T07:25:06.660 に答える
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.");
 }

必要に応じてDirectionを使用します。

ハッピーコーディング...

于 2012-01-25T07:25:17.383 に答える