uiviewアニメーションブロックアニメーションビューのサブビューではありません

StackOverflow https://stackoverflow.com/questions/4055113

質問

次のコードでアニメーションを達成することはできません。

if (self.segmentControl.selectedSegmentIndex == 0) {
    [UIView transitionFromView:tableView
                        toView:mapView
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromLeft
                    completion:nil
         ];
    }
if (self.segmentControl.selectedSegmentIndex == 1) {
    [UIView transitionFromView:mapView
                        toView:tableView
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromRight
                    completion:nil
         ];
}

ビューは実際には交換されていますが、アニメーションはありません。とても奇妙です。また、交換しようとしました mapViewtableViewself.view.subviews そのようです (objectAtIndex:0 aです toolBar):

if (self.segmentControl.selectedSegmentIndex == 0) {
    [UIView transitionFromView:[self.view.subviews objectAtIndex:1]
                        toView:[self.view.subviews objectAtIndex:2]
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromLeft
                    completion:nil
         ];
    }
if (self.segmentControl.selectedSegmentIndex == 1) {
    [UIView transitionFromView:[self.view.subviews objectAtIndex:2]
                        toView:[self.view.subviews objectAtIndex:1]
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromRight
                    completion:nil
         ];
}
役に立ちましたか?

解決

間違ったオプションを使用しています。この方法では、使用する必要があります 定数 UIViewAnimationオプションTransitionFlipFromLeft…Right 代わりは。

古い定数 UIViewAnimationTransitionFlipFromLeft…Right ブロック以外の方法にのみ使用する必要があります +setAnimationTransition:…. 。これらの定数はそれぞれ値1と2を持っていますが、上記の定数は値1 << 20および2 << 20を持っていますが、これはまったく異なります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top