كيف يمكنني جعل الرسم الانتهاء من NSCOLLECTIONVIEW قبل العرض الذي يحتوي على أنه مرئي؟

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

  •  28-09-2019
  •  | 
  •  

سؤال

أحاول تنظيف واجهة المستخدم على طلبي (تم إنشاؤه لمدة 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];   
}
هل كانت مفيدة؟

المحلول

المشكلة ليست أن طريقة عرض المجموعة لم تنته من الرسم ، فهي تحفز إضافة وإزالة المشاهدات الفرعية. قد يكون من الممكن إنشاء معاملة هذا يعطل إجراءات الطبقة أثناء إعادة تحميل محتوى عرض المجموعة. إدراج 2 (تعطيل تصرفات الطبقة مؤقتًا) يوضح كيفية القيام بذلك. لم أختبر هذا ، لذلك لا أعرف ما إذا كان هذا سيفعل ما تريد ، لكن هذا هو المكان الذي سأبدأ فيه.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top