2

タブベースのアプリケーションがあり、スワイプ ジェスチャを使用してビュー コントローラをナビゲートしたいと考えています。私は試した:

    - (IBAction)swipeLeftDetected:(UIGestureRecognizer *)sender {
UISecondViewController *second =[[UISecondViewController alloc] initWithNibName:@"UISecondViewController" bundle:nil];
second.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:second animated:YES];

} 

これとペア:

    - (void)viewDidLoad; {
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc]    initWithTarget:self action:@selector(swipeLeftDetected:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeRecognizer];

}

しかし、スワイプでクラッシュします。何か助けはありますか?ありがとう!

4

1 に答える 1

0

あなたのコードは私の Xcode でうまく動作します。のみ変更:

UISecondViewController *second =[[UISecondViewController alloc] initWithNibName:@"UISecondViewController" bundle:nil];

に:

SecondViewController *second =[[SecondViewController alloc] init];

UISecondViewController クラスを持っていないためです。プロジェクトに UISecondViewController.xib があることを確認してください。そうしないとクラッシュします。しかし、ここに問題があるかどうかはわかりません。

于 2013-05-24T09:42:24.717 に答える