簡體   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