非常に簡単な移行を試みています:1つのビューは画面の半分を左に移動し、2番目(「to」)ビューは画面の半分に移動します。カスタムビューコントローラの移行中にちらつくiOS 7
アニメーションは動作していますが、アニメーションを逆にするとちらつきがあります。別のフレームを設定しても、「to」ビュー(元のビュー)は0,0の原点で表示されます。
私はビュー階層をダンプしました。フレームは正しく設定されていますが(-100 0; 320 480)、それにもかかわらず0,0に表示されます。ビューのスクリーンショットはアニメーションのどこかにキャッシュされていますか?
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *container = [transitionContext containerView];
CGRect offsetCoverRect = CGRectMake(-100.0, 0.0, 320, 480);
CGRect detailsRect = CGRectMake(-100.0 + 320.0, 0.0, 320, 480);
CGRect detailsOutsideRect = CGRectMake(320.0, 0.0, 320, 480);
CGRect normalRect = CGRectMake(0.0, 0.0, 320, 480);
if (self.revealDetails)
{
toViewController.view.frame = detailsOutsideRect;
[container addSubview:toViewController.view];
}
else
{
[container insertSubview:toViewController.view belowSubview:fromViewController.view];
// reversing… set the frame to the original offset (shows at 0,0 for a moment)
toViewController.view.frame = offsetCoverRect;
}
[UIView animateKeyframesWithDuration:2 delay:0 options:0 animations:^{
if (self.revealDetails)
{
fromViewController.view.frame = offsetCoverRect;
toViewController.view.frame = detailsRect;
}
else
{
fromViewController.view.frame = detailsOutsideRect;
toViewController.view.frame = normalRect;
}
} completion:^(BOOL finished) { [transitionContext completeTransition:finished]; }];
}
更新:
UIModalPresentationCustom
に関連しているようです。私はこれを使用して、遷移が完了したときにfromビューが削除されないようにする必要があります。しかし、逆遷移のビューコントローラは、0,0から始まると仮定しているようです。
アップデート2:
次のコードで再現することが非常に簡単:上記
UIView *snapshot = [containerView snapshotViewAfterScreenUpdates:NO];
[containerView addSubview:snapshot];
は関係なく、私が前に設定したもの実際のフレームまたは中央、画面の中央に表示する表示されませんアニメーション。
これは 'UIViewControllerContextTransitioning'インスタンスの' initialFrameForViewController: 'に関連していますか? – Mark
この問題はデバイスを使用しているのか、シミュレータだけを使用していますか? – MatterGoal
@MatterGoalもデバイス上にあります。私が何を設定しても、ビューが0,0から始まるようです。 – Mark