私は自分のアプリケーション (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];
}