2

さまざまUIStoryboardSegueUIViewControllers. アニメーションは期待どおりに機能し、ほとんどの場合、UIStoryboardSegueシミュレータとデバイスの両方で期待どおりに表示されます。

ただし、セグエが完了した後、古いUIViewController フラッシュが数分の 1 秒後に表示されることがありUIStoryboardSegueます。その結果、私が期待しているスムーズな移行が妨げられます。残念ながら、この動作のパターンを識別できません。

以下に、セグエを管理するために使用しているアプローチのベアボーン バージョンを含めました。スムーズな移行を保証するためのより信頼できる方法はありますか? 私は何か間違ったことをしていますか?繰り返しますが、ほとんどの場合、セグエは私が望むとおりに見えます。

- (void)perform
{
    self.window = [[[UIApplication sharedApplication] delegate] window];
    UIViewController *source = (UIViewController *) self.sourceViewController;
    UIViewController *dest = (UIViewController *) self.destinationViewController;

    [self.window insertSubview:dest.view.window belowSubview:source.view];

    self.segueLayer = [CALayer layer];
    // Create and add a number of other CALayers for displaying the segue,
    // adding them to the base segueLayer

    // Create and add CAAnimations for animating the CALayers
    // (code omitted for the sake of space)

    [self.window addSubview:dest.view];
    [self.window.layer addSublayer:self.segueLayer];

    [source.view removeFromSuperview];
}

- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)isFinished
{
    UIViewController *source = (UIViewController *) self.sourceViewController;
    UIViewController *dest = (UIViewController *) self.destinationViewController;

    if (isFinished)
    {
        // Remove and deallocate the CALayers previously created 
        [self.segueLayer removeFromSuperlayer];
        self.segueLayer = nil;
        self.window.rootViewController = dest;
    }
}
4

1 に答える 1

2

したがって、CAAnimationsは実際のレイヤーの値を変更しませんが、関連するレイヤーの値を変更しますpresentationLayer。をに設定するとfillMode、アニメーションの完了後にの値が元に戻らないようになります。ただし、アニメーションのプロパティが(デフォルトでは)に設定されている場合、レイヤーの外観もアニメーション前の状態に戻すことができます。kCAFillModeForwardspresentationLayerremovedOnCompletionYES

コールバックは潜在的な復帰後に呼び出される可能性が高く、animationDidStop:タイミングが正確ではないため、復帰が常に表示されるとは限らない理由が説明されます。

于 2012-09-17T22:50:28.987 に答える