2013-04-24 73 views
1

我正在使用uitapgestures,我想要一个uiviewcontroller导航到另一个控制器与翻转动画。我尝试使用uimodaltransitionflip,它的工作原理,但下一个控制器上的按钮将无法工作。我该怎么做呢?如何使uiviewcontroller翻转到下一页?

对于此代码,该按钮在另一页上工作。

- (void)imageView1DoubleTapped:(UITapGestureRecognizer *)gestureRecognizer 
{ 
    GFStoryBoardViewController *gfsb = [[GFStoryBoardViewController alloc]initWithNibName:nil bundle:nil]; 



    [self.navigationController pushViewController:gfsb animated:YES]; 

} 

对于这个代码的按钮不会下一页

- (void)imageView2DoubleTapped:(UITapGestureRecognizer *)gestureRecognizer 
{ 
    SBStoryBoardViewController *sbsb = [[SBStoryBoardViewController alloc]initWithNibName:nil bundle:nil]; 

    sbsb.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

    [self.navigationController presentModalViewController:sbsb animated:YES]; 

} 
+1

你能为我们提供一些代码。你确定问题是翻转?可能该按钮在您的控制器上不起作用? – NDY 2013-04-24 07:38:39

+0

我修改了上面的代码。请看一下。谢谢! – benedict 2013-04-24 08:06:55

回答

0

你需要一个根视图控制器作为一个容器视图保存动画工作。这可以是自定义容器视图控制器或UIWindow。 (即[UIApplication的sharedApplication] .window)

那么做到这一点:

[UIView transitionWithView:rootViewController.view duration:0.40 options:UIViewAnimationOptionTransitionFlipFromRight animations:^ 
    { 
     [currentViewController.view removeFromSuperView]; 
     //This will take up the whole screen of the container view. If using UIWindow 
     //If using UIWindow, you may need to adjust to accomodate the status bar. 
     newViewController.view.frame = rootViewController.view.bounds 
     [rootViewController.view addSubView:newViewController.view]; 

    } completion:^(BOOL complete) 
    { 
     //Anything that you want to happen afterwards 
    }];