我无法实现用下面的代码的任何动画:

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:0toolBar):

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,其是完全不同的。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top