[英]UIView animation block not animation view's subviews
I am unable to achieve any animation with the following code: 我无法使用以下代码实现任何动画:
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
];
}
The views are actually swapping, but just without any animation. 视图实际上是交换,但没有任何动画。 It's quite strange.
这很奇怪。 I have also tried to swap
mapView
and tableView
with self.view.subviews
like so ( objectAtIndex:0
is a toolBar
): 我也曾尝试交换
mapView
和tableView
与self.view.subviews
像这样( objectAtIndex:0
是一个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
];
}
You are using the wrong options. 您使用的是错误的选项。 With this method, you should use the constants
UIViewAnimation
and Option TransitionFlipFromLeft
…Right
instead. 使用此方法,您应该使用常量
UIViewAnimation Option TransitionFlipFromLeft
和…Right
而不是。
The old constants UIViewAnimationTransitionFlipFromLeft
and …Right
should only be used for the non-block-based method +setAnimationTransition:…
. 旧常量
UIViewAnimationTransitionFlipFromLeft
和…Right
应仅用于非基于块的方法+setAnimationTransition:…
These constants have values 1 and 2 respectively, while the ones I mentioned above have values 1 << 20 and 2 << 20, which are totally different. 这些常数分别具有值1和2,而我上面提到的值具有值1 << 20和2 << 20,它们完全不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.