的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
是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
];
}
解决方案
您使用了错误的选项。使用这种方法,你应该使用的常数UIViewAnimationOptionTransitionFlipFromLeft
和…Right
代替。
旧常数UIViewAnimationTransitionFlipFromLeft
和…Right
应该仅被用于非基于块的方法+setAnimationTransition:…
。这些常数分别具有值1和2,虽然我上面提到的那些具有值1 << 20和2 << 20,其是完全不同的。
不隶属于 StackOverflow