3

NSAttributedStringを介してNSTextFieldに画像の添付ファイルを配置するときに、クリックまたは変更すると、画像が消えます。どうしたの?

NSTextAttachment* attachment = [[NSTextAttachment alloc] init];
NSImage *symbolImage = [NSImage imageNamed:@"enabled.png"];
NSLog(@"%@", symbolImage);
NSTextAttachmentCell *anAttachmentCell = [[NSTextAttachmentCell
                                           alloc] initImageCell:symbolImage];
[attachment setAttachmentCell:anAttachmentCell];
return [NSAttributedString attributedStringWithAttachment:attachment];
4

2 に答える 2

4

ここに画像の説明を入力

実際、修正は非常に簡単です。画像を表示する必要があるフィールドで「リッチ テキスト」を有効にするだけです。

テキスト添付ファイルが挿入されると、フォーカスを別のビューに変更した後でも画像がそこに残ります。

于 2015-02-11T09:01:59.080 に答える