質問

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>"

上記の方法でアクションの順序を変更し、私のtableViewにreloadDataを送信して、結果に影響を及ぼさなかった。

予想通りsetIndicatorImageが働くように思わ、何とか画像がヘッダーに表示されていない、または少なくとも表示されません。

私がここで行方不明ですか?

EDIT

コードによるアプリケーションのウィンドウのメインビューにNSViewControllerのサブクラスを置くために使用されます:

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

[view display];
[mainView display];
役に立ちましたか?

解決

はOK、私はいくつかの簡単な十分な回避策を見つけました

[[[tableView tableColumnWithIdentifier:[lastSortDescriptor key]] headerCell] 
setStringValue:[columnName stringByAppendingString:([lastSortDescriptor ascending]) ? @"  ▲" : @"  ▼"]];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top