Я пытаюсь очистить пользовательский интерфейс в моем приложении (создан для 10.5), и одна вещь, которая довольно раздражает, заключается в том, что, когда я перехожу в библиотеку, я перезагружаю содержимое, и nscollectionview, отображающий элементы, выцветает из старого содержимогодо появления новых. Я не возражаю против появления / исчезновения старых / новых элементов, но то, как я запрограммировал обмен представлениями, должно привести к перезагрузке библиотеки до того, как nsview, содержащий nscollectionview, будет вставлен вглавное окно.
Кто-нибудь раньше сталкивался с подобными проблемами?
Вот сокращенная версия того, как происходит обмен между различными частями приложения в библиотеке:
В главном контроллере:
-(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];
}