سؤال

NSDisableScreenUpdates();

[self.productsArrayController setFetchPredicate:predicate];
[self.productsArrayController setSortDescriptors:sortDescriptors];

[self.productsArrayController fetchWithRequest:[self.productsArrayController defaultFetchRequest] merge:YES error:nil];

NSSortDescriptor *lastSortDescriptor = [sortDescriptors lastObject];
[tableView setHighlightedTableColumn:[tableView tableColumnWithIdentifier:[lastSortDescriptor key]]];
[tableView setIndicatorImage:[NSImage imageNamed: ([lastSortDescriptor ascending]) ? @"NSAscendingSortIndicator" : @"NSDescendingSortIndicator"]
                          inTableColumn:[tableView tableColumnWithIdentifier:[lastSortDescriptor key]]];        

NSLog(@"currentImage: %@", [tableView indicatorImageInTableColumn:[tableView tableColumnWithIdentifier:[lastSortDescriptor key]]]); /* DEBUG LOG */

NSEnableScreenUpdates();

الكود أعلاه لا يضبط صورة فرز مثلث. أقوم بتعيين واصفات فرز متعددة ، ولكن بعد تغييرها إلى واحدة ، يبدأ في عرض الصورة الصحيحة في رأس العمود. في كلتا الحالتين ، يوضح لي CurrentImage أنه يتم تعيين الصورة الصحيحة (نفس الشيء للترتيب الهبوط):

currentImage: <NSImage 0x200495fc0 Name=NSAscendingSortIndicator Size={9, 9} Reps=(
    "NSBitmapImageRep 0x20049f480 Size={9, 9} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=9x9 Alpha=YES Planar=NO Format=0 CurrentBacking=<CGImageRef: 0x2004a9e80>"

تغيير ترتيب الإجراءات في الأسلوب أعلاه وإرسال RELOADDATA إلى عرض الجدول الخاص بي ، لم يكن له أي تأثير على النتائج.

يبدو لي أن setIndicatorImage يعمل كما هو متوقع ، ولكن لا يتم عرض الصورة بطريقة ما في الرأس ، أو على الأقل غير مرئية.

ماذا أفتقد هنا؟

تعديل

يتم استخدام الرمز لوضع فئة فرعية من NSViewController في العرض الرئيسي لنافذة التطبيق بواسطة:

// adding view inside the main view
[mainView addSubview:view];
[view setFrame:[mainView bounds]];

[view display];
[mainView display];
هل كانت مفيدة؟

المحلول

حسنًا ، لقد وجدت للتو بعض العمل البسيط بما فيه الكفاية:

[[[tableView tableColumnWithIdentifier:[lastSortDescriptor key]] headerCell] 
setStringValue:[columnName stringByAppendingString:([lastSortDescriptor ascending]) ? @"  ▲" : @"  ▼"]];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top