UIView 动画块不是动画视图的子视图
我无法使用以下代码实现任何动画:
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
是一个工具栏
):
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
];
}
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
):
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
];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用了错误的选项。使用此方法,您应该使用 常量
UIViewAnimationOptionTransitionFlipFromLeft
和…Right
代替。旧常量
UIViewAnimationTransitionFlipFromLeft
和...Right
只能用于非基于块的方法+setAnimationTransition:...
。这些常数的值分别为 1 和 2,而我上面提到的常数的值为 1 << 20和2《 20个,完全不同。You are using the wrong options. With this method, you should use the constants
UIViewAnimationOptionTransitionFlipFromLeft
and…Right
instead.The old constants
UIViewAnimationTransitionFlipFromLeft
and…Right
should only be used for the non-block-based method+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.