2012-09-17 31 views
0

我有兩個UIViews VW1和VW2在相同的UIViewController。 我想翻轉從VW1到VW2的權利,並使用下面的代碼,我不知道如何以及在哪裏調用該方法?向右翻轉UIView1到UIView2

-(void)FlipFromRight 
{ 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1.0]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:uiView2 cache:YES]; 

    [UIView commitAnimations]; 
} 

上面的代碼不適用於我。

+0

我想在屏幕上從右向左滑動時在視圖之間做翻轉。我也嘗試在視圖之間使用滑動手勢,並且它不工作,它僅適用於不同的ViewControllers –

+1

嘗試隱藏並僅顯示一個訴iew在上面的方法..定義條件的方法和顯示view1,如果它隱藏否則顯示view2 ... –

回答

1

你需要做的:

if ([VW1 superview]) 
    { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:aTableBGView cache:NO]; 

     [VW1 removeFromSuperview]; 
     [mainView addSubview:VW2]; 
     [mainView sendSubviewToBack:VW1]; 
    } 
    else 
    { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:aTableBGView cache:NO]; 

     [[mainView viewWithTag:2001] removeFromSuperview]; // VW2's tag ID 
      [mainView addSubview: VW1]; 
     [mainView sendSubviewToBack: VW2]; 
    } 
    [UIView commitAnimations]; 
0

在導航欄上或MainViewcontroller添加一個這裏的UIButton像名「btnSwipe」,之後乾脆放棄例如即「左」按鈕標題。 後,讓動作事件與此波紋管方法

-(IBAction)FlipFromRight:(id)sender 
{ 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1.0]; 
    if ([btnSwipe.titleLabel.text isEqualToString:@"Left"]) 
    { 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:uiView1 cache:YES]; 
[btnDraw setTitle:@"Right" forState:UIControlStateNormal]; 
    } 
else{ 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:uiView2 cache:YES]; 
[btnDraw setTitle:@"Left" forState:UIControlStateNormal]; 
} 

    [UIView commitAnimations]; 
} 

這裏只是給IBAction爲從廈門國際銀行,以btnSwipe,也將努力

我希望這是對你有用..

:)