1

私の NSProgressIndicator は、別のビューに切り替えるとビューでアニメーション化され、元の NSProgressIndicator が消えます。

なぜ?

別のビューに切り替えるための私のコードは次のとおりです

    - (void)switchToView:(NSView *)newView withAnimate:(BOOL)animate
{
        if ([[rootView subviews] count] != 0)
        {
            [rootView setWantsLayer:YES];
            [rootView displayIfNeeded];

            NSTimeInterval duration = [[self window] animationResizeTime:newFrame];
            [NSAnimationContext beginGrouping];
            [[NSAnimationContext currentContext] setDuration:0.25];
            [[rootView animator] replaceSubview:[[rootView subviews] objectAtIndex:0] with:newView];
            [NSAnimationContext beginGrouping];
            if (duration > 0.25) {
                [[NSAnimationContext currentContext] setDuration:0.25];
            }
            else{
                [[NSAnimationContext currentContext] setDuration:duration];
            }
            [[[self window] animator] setFrame:newFrame display:YES animate:YES];
            [NSAnimationContext endGrouping];
            [NSAnimationContext endGrouping];

            [self performSelector:@selector(endAnimation) withObject:nil afterDelay:0.25f];
            }


    }

    -(void)endAnimation{
          [[ _mainWindow contentView] setWantsLayer:NO];
    }

ビューを置き換えて、フェードアウトアニメーション NSProgressIndicator を作成し、ビューで常にアニメーション化します。

4

1 に答える 1

0

私はこれを自分で解決しました。皆さんの役に立つと思います。

ビューを NSProgressIndicator に置き換える前に、NSProgressIndicator を停止します。

次に、ビューを新しいビューに置き換えます。元に戻す場合は、NSProgressIndicator を - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay; で開始します。方法は、delay=0に設定するだけでOKです。

xib ファイルでは、NSProgressIndicator DisplayWhenStopped を YES に設定する必要があります。

そしてそれはうまくいくでしょう。

次に、理由は 10.6.5 以降です。少なくとも OS X 10.6.5 以降では、indetermined-progress-indicator の wantLayer プロパティを YES に設定するとすぐに、アニメーションがすぐに停止します。

なので、すぐに止まる前に、自分で止めて、使いたいときに起動します。

注意: システムよりも自分で停止する必要があります。システムが停止するとうまく機能しません。

于 2013-08-20T02:20:10.523 に答える