4
NSTextAttachment
イメージをOS XアプリケーションのNSTextView
で動作させることに問題があります。NSTextAttachmentイメージはNSTextViewでは表示されません(しかし、UITextViewでは)?
NSTextAttachment
の画像は表示されません。しかし、それはまだ正しく設定されているようです。 NSTextView
の内容をコピーして、それを再び例えばTextEdit.app、貼り付けられたテキストに画像が正しく含まれています。ここで
は、問題を再現する最小限の遊び場ですので、代わりにココア、それは完璧に動作UIKitに使用して、iOS用
:出力を期待
import Cocoa
let img = NSImage(named: "Checked")
let textView = NSTextView(frame: NSMakeRect(0, 0, 254, 64))
let attrstr = NSMutableAttributedString(string: "Test")
let attch = NSTextAttachment()
attch.image = img
attrstr.appendAttributedString(NSAttributedString(attachment: attch))
textView.textStorage!.setAttributedString(attrstr)
textView
罰金:
import UIKit
let img = UIImage(named: "Checked")
let textView = UITextView(frame: CGRectMake(0.0, 0.0, 200.0, 44.0))
let attrstr = NSMutableAttributedString(string: "Test")
let attch = NSTextAttachment()
attch.image = img
attrstr.appendAttributedString(NSAttributedString(attachment: attch))
textView.attributedText = attrstr
textView
私はどちらの遊び場がhereをダウンロードすることができXCodeの7を使用しています。
どのようなアイデアも大歓迎です。事前に感謝します!
ありがとうございます。ほんとうにありがとう! – rkusa