nscollectionViewを含むnscollectionViewの描画を描画するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/3060238

  •  28-09-2019
  •  | 
  •  

質問

私はアプリケーションのUIをクリーンアップしようとしています(10.5用に構築されています)。かなり面倒なことの1つは、ライブラリに交換すると、コンテンツとアイテムを表示する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];   
}
役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top