2009-09-03 10 views
2

私の息子は自分のビューの「完了」ボタンを押すと直前のビューにフリップし、一度フリップを開始して1回以上表示するトランジション(反転)しています。 2回目以降のヒットは、同じアクションをもう一度トリガーし、ビューが表示されずに終了するなど、興味深い結果を作成しますが、基になるUIWindowです。UIViewが遷移中にボタンを押す

私が呼び出す必要があることを考えています:アニメーションが終了した後、最終的なビューに

[coming.view setUserInteractionEnabled: YES]; 

をフリップ遷移に関与ビューの両方で

[coming.view setUserInteractionEnabled: NO]; 
[going.view setUserInteractionEnabled: NO]; 

をし、その後

どのビューも移行中にタップをグローバルに無効にするには、これよりも優れていると思っていました。どう思いますか?

- (void)switchTwoViews:(UIViewController *)view1 otherView:(UIViewController *)view2 
{ 
    /* 
    This method is called to switch views. 
    It flips the displayed view from the main view to the flipside view and vice-versa. 
    */ 

    UIViewController *coming = nil; 
    UIViewController *going = nil; 
    UIViewAnimationTransition transition; 

    [view1.view setUserInteractionEnabled: NO]; 
    [view2.view setUserInteractionEnabled: NO]; 
    if (view1.view.superview == nil) { 
     coming = view1; 
     going = view2; 
     transition = UIViewAnimationTransitionFlipFromLeft; 
    } 
    else { 
     coming = view2; 
     going = view1; 
     transition = UIViewAnimationTransitionFlipFromRight; 
    } 
    // coming.view.frame = [UIScreen mainScreen].applicationFrame; 

    // going.view.alpha = 1.0;  //uncomment these lines if we want fading of views 
    // coming.view.alpha = 0.0; 

    NSArray *viewArray = [[NSArray alloc] initWithObjects:coming, going, nil]; 
    [coming viewWillAppear:YES]; 
    [going viewWillDisappear:YES]; 
    [UIView beginAnimations:@"View Flip" context:viewArray]; { 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDidStopSelector:@selector(animationDidEnd:finished:context:)]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     //  coming.view.alpha = 1.0;  //uncomment these lines if we want fading of views 
     //  going.view.alpha = 0.0; 

     [UIView setAnimationTransition:transition forView:self.view cache:YES]; 
     [self.view addSubview: coming.view]; 
    } 
    [UIView commitAnimations]; 

} 

- (void) animationDidEnd:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{ 
    NSArray *viewArray = context; 
    [((UIViewController *)[viewArray objectAtIndex:1]).view removeFromSuperview]; 
    [[viewArray objectAtIndex:1] viewDidDisappear:YES]; 
    [[viewArray objectAtIndex:0] viewDidAppear:YES]; 
    [[[viewArray objectAtIndex:0] view] setUserInteractionEnabled: YES]; 
    [viewArray release]; 
} 

答えて

1

がsetUserInteractionEnabled:

はここで全体のビューの切り替えコードで移動するための方法のようです。異議はありますか?

関連する問題