2011-12-14 5 views
2

NSAttributedStringを介してNSTextFieldに画像添付ファイルを配置すると、そのファイルをクリックまたは変更すると画像が消えます。どうしましたか?添付ファイル付き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]; 
+0

NSAttributedStringを介して画像添付ファイルをどのようにしているかをコードで表示できますか? –

+0

これを解決しましたか?私はリンクで同じ問題を抱えています:http://stackoverflow.com/questions/8684972/nstextfields-attributed-string-is-delayed-in-rendering – d2kagw

+0

私はしませんでした: – darvin

答えて

2

enter image description here

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

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

関連する問題