1

新しい iOS 7 カスタム トランジション API をテストしていますが、ナビゲーション コントローラーのケースに問題があります。私はこれで今のところ非常に基本的なテストを試みました:

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
    [transitionContext completeTransition:YES];
}

ご想像のとおり、このコードはアニメーションなしでトランジションを完了する以外には何もしません。しかし、ここに問題があります。コントローラーの存在/破棄で正常に機能している場合、プッシュおよびポップメソッドで表示されるのは、機能[transitionContext completeTransition:YES]しなかったかのように黒い画面だけです。

このメソッドは常に呼び出されるため (present、dismiss、push、pop)、すべてのデリゲート プロパティとデリゲート メソッドを適切に設定しました。

誰かがすでにこの問題に直面していますか?

4

1 に答える 1

3

このようなものをもっと試してみてください。私も問題を抱えていましたが、これはそれをより理解するのに役立ちました

- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{

    // 1. obtain state from the context
    UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    CGRect finalFrame = [transitionContext finalFrameForViewController:toViewController];

    // 2. obtain the container view
    UIView *containerView = [transitionContext containerView];

    // 3. set initial state
    CGRect screenBounds = [[UIScreen mainScreen] bounds]; toViewController.view.frame =
    CGRectOffset(finalFrame, 0, screenBounds.size.height); 

    // 4. add the view
    [containerView addSubview:toViewController.view];

    // 5. animate
    NSTimeInterval duration = [self transitionDuration:transitionContext];

    [UIView animateWithDuration:duration animations:^{

        toViewController.view.frame = finalFrame; 

     } completion:^(BOOL finished) {

        // 6. inform the context of completion
        [transitionContext completeTransition:YES];

    }];
}

ソース: http://www.raywenderlich.com/forums/viewtopic.php?f=37&t=8851

于 2013-10-02T20:26:21.987 に答える