Ios UIView动画块不是动画视图';s子视图
我无法使用以下代码实现任何动画:Ios UIView动画块不是动画视图';s子视图,ios,uiviewanimation,uiviewanimationtransition,Ios,Uiviewanimation,Uiviewanimationtransition,我无法使用以下代码实现任何动画: if (self.segmentControl.selectedSegmentIndex == 0) { [UIView transitionFromView:tableView toView:mapView duration:1.0 options:UIViewAnimationTransitionFlipFromL
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.subview
进行类似的交换(objectAtIndex:0
是工具栏
):
你使用了错误的选项。使用此方法时,应使用
旧常量
UIViewAnimationTransitionFlipFromLeft
和…Right
只能用于非基于块的方法+setAnimationTransition:…
。这些常数的值分别为1和2,而我上面提到的那些常数的值为1,非常感谢!我猜这是Xcode中的一个bug,它在编译时不建议甚至不识别这个选项(虽然它编译时没有错误,只是没有将文本颜色更改为“OK”编译选项)。@Canada:这不是Xcode中的bug,而是C标准(gcc
)不要阻止不同的enum
s的常量混淆。是的,对不起,我看了更多的类,只是看到了编译器的东西。谢谢:)@Canada您之所以没有收到编译器警告,是因为它是一个枚举,当您将其归结为本质时,它只是一个整数。这意味着在没有“Option”的情况下传入值是完全有效的,因为它的值也是一个整数
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
];
}