如何通过滑动手势以编程方式切换视图控制器?

时间:2013-01-17 06:03:40

标签: ios

我想将推送导航放入滑动。

我想在滑动手势上调用此方法。

- (IBAction)MakeADifferenceButtonPressed:(id)sender {
    MakeADifferenceViewController *makeADifferenceView = [[MakeADifferenceViewController alloc] initWithNibName:@"MakeADifferenceViewController"  bundle:nil];
    [self.navigationController pushViewController:makeADifferenceView animated:YES];
    [makeADifferenceView release];
}

任何人请帮助我。我是iphone的新手。

1 个答案:

答案 0 :(得分:2)

使用此代码在您当前的UIView中添加UISwipeGestureRecognizerDirectionLeft

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