繁体   English   中英

UIView动画块不是动画视图的子视图

[英]UIView animation block not animation view's subviews

我无法使用以下代码实现任何动画:

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
         ];
}

视图实际上是交换,但没有任何动画。 这很奇怪。 我也曾尝试交换mapViewtableViewself.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
         ];
}

您使用的是错误的选项。 使用此方法,您应该使用常量UIViewAnimation Option TransitionFlipFromLeft…Right而不是。

旧常量UIViewAnimationTransitionFlipFromLeft…Right应仅用于非基于块的方法+setAnimationTransition:… 这些常数分别具有值1和2,而我上面提到的值具有值1 << 20和2 << 20,它们完全不同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM