Как установить изображение индикатора на столбце с несколькими дескрипторами сортировки?

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

Вопрос

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();

Вышеуказанный код не устанавливает изображение сортировки треугольника. Я устанавливаю несколько дескрипторов сортировки, но после изменения его на один он начинает отображать правильное изображение в заголовке столбца. В обоих случаях CurrageImage показывает, что установлено правильное изображение (то же самое для поручения убывания):

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