0

私は自分のアプリケーション (10.5 用にビルド) の UI をクリーンアップしようとしていますが、ライブラリにスワップするときにコンテンツをリロードすると、アイテムを表示する nscollectionview が古いコンテンツをフェードアウトする前にフェードアウトすることはかなり面倒です。古い/新しいアイテムのフェードイン/フェードアウトは気にしませんが、ビューのスワッピングをプログラムした方法では、nscollectionview を含む nsview がメイン ウィンドウに挿入される前にライブラリのリロードが行われるはずです。 .

誰もが前にこの種の問題を抱えていましたか?

アプリケーションのさまざまな部分からライブラリへのスワップがどのように行われるかの要約版を次に示します。

メインコントローラーで:

-(void)setMainPaneToLibrary {
    if(viewState == VIEW_STATE_LIBRARY)
        return;
    [libraryController refreshDevices:self];
    [libraryController refreshLibraryContents];

    [menuController setSelectionToIndex:0];
    viewState = VIEW_STATE_LIBRARY;

    [self removeSubview]; //clear the area
    [mainPane addSubview:[libraryController view]];
}

ライブラリ コントローラで:

-(void)refreshLibraryContents {
    [self loadLibraryContents:[rootDir stringByAppendingPathComponent:currentDir]];
}

-(void)loadLibraryContents:(NSString *)folderToLoad {

    int i;
    int currentSelection = [libraryArrayController selectionIndex]; //used to preserve selection and smooth folder changing

    [libraryArrayController setContent:nil];

    //expand the path to load
    folderToLoad = [folderToLoad stringByExpandingTildeInPath];

    NSFileManager * fileManager = [NSFileManager defaultManager]; 
    //load the files in the folder
    NSArray * contents = [fileManager directoryContentsAtPath:folderToLoad];

    //create two seperate arrays for actual files and folders - allows us to add them in order
    NSMutableArray * directories = [[NSMutableArray alloc] init];
    NSMutableArray * musicFiles = [[NSMutableArray alloc] init];

//... a load of stuff filling the file arrays ...

    for(i=0;i<[directories count];i++) {
    [libraryArrayController addObject:[directories objectAtIndex:i]];
    }
    for(i=0;i<[musicFiles count];i++) {
    [libraryArrayController addObject:[musicFiles objectAtIndex:i]];
    }

    if(currentSelection >= 0) {
    [libraryArrayController setSelectionIndex:currentSelection];
    }

    [directories release];
    [musicFiles release];   
}
4

1 に答える 1

-1

問題は、コレクション ビューの描画が完了していないことではなく、サブビューの追加と削除がアニメーション化されていることです。コレクション ビューのコンテンツをリロードしているときに、レイヤー アクションを無効にするトランザクションを作成できる場合があります。リスト 2 (レイヤーのアクションを一時的に無効にする) は、これを行う方法を示しています。私はこれをテストしていないので、これがあなたの望みどおりになるかどうかはわかりませんが、ここから始めます。

于 2010-06-17T16:47:13.433 に答える