试图通过在ViewController A上捏视图来打开ViewController B.

时间:2013-07-30 11:59:18

标签: ios uipinchgesturerecognizer

我希望能够通过在当前viewController上捏视图来导航到另一个viewController。

控制台显示视图正在识别捏合手势并将其记录下来。

但是我不知道如何触发pinch来打开另一个ViewController。

以下是我用来实现此目的的代码。

- (void)viewDidLoad
{
    [super viewDidLoad];

    //Pinch Gesture
    UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
    [self.view addGestureRecognizer:pinchGesture];
} 


- (IBAction)handlePinchGesture:(UIPinchGestureRecognizer *)sender
{

    NSLog(@" ((UIPinchGestureRecognizer *) sender).scale %f", ((UIPinchGestureRecognizer *) sender).scale);
    if (((UIPinchGestureRecognizer *)sender).scale > 1.0)
    {
        //I tried to use a different method to instantiate AustraliaViewController but it    //doesn't work 
        //[self.storyboard instantiateViewControllerWithIdentifier:@"Australia"];

        AustraliaViewController *aust = [[AustraliaViewController alloc] initWithNibName:@"Australia" bundle:Nil];
        aust.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentViewController:aust animated:YES completion:Nil];
    }

        [self showInfo:(id)sender];

}

0 个答案:

没有答案