uiviewアニメーションブロックアニメーションビューのサブビューではありません
-
27-09-2019 - |
質問
次のコードでアニメーションを達成することはできません。
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
];
}
ビューは実際には交換されていますが、アニメーションはありません。とても奇妙です。また、交換しようとしました mapView
と tableView
と self.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を持っていますが、これはまったく異なります。
所属していません StackOverflow