2013-04-24 46 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 
    }];