Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何使用表情符号制作NSTextfield?_Macos_Cocoa_Nstextfield_Rich Text Editor_Emoticons - Fatal编程技术网

Macos 如何使用表情符号制作NSTextfield?

Macos 如何使用表情符号制作NSTextfield?,macos,cocoa,nstextfield,rich-text-editor,emoticons,Macos,Cocoa,Nstextfield,Rich Text Editor,Emoticons,我正在尝试在mac上开发XMPP聊天客户端。 我想让带有表情符号的聊天文本字段像Skype一样 我试着这样做: NSMutableAttributedString*mastring=[[NSMutableAttributedString alloc]initWithAttributedString:astring]; NSImage*emoticon=[NSImage imagename:@“smile.png”]; NSTextAttachmentCell*attachmentCell=[[N

我正在尝试在mac上开发XMPP聊天客户端。 我想让带有表情符号的聊天文本字段像Skype一样

我试着这样做:

NSMutableAttributedString*mastring=[[NSMutableAttributedString alloc]initWithAttributedString:astring]; NSImage*emoticon=[NSImage imagename:@“smile.png”]; NSTextAttachmentCell*attachmentCell=[[NSTextAttachmentCell alloc]initImageCell:emoticon]; NSTextAttachment*附件=[[NSTextAttachment alloc]init]; [附件setAttachmentCell:attachmentCell]; NSAttributedString*attributedString=[NSAttributedString attributedStringWithAttachment:attachment]; [allstring insertAttributedString:attributedString索引:1]; 因此,我将表情图标图像插入到NSTextField中,但无法将表情图标图像复制/粘贴到另一个NSTextField中。 请给我技术。谢谢大家

NSMutableAttributedString* mastring = [[NSMutableAttributedString alloc] initWithAttributedString:astring]; NSImage * emoticon = [NSImage imageNamed:@"smile.png"]; NSTextAttachmentCell *attachmentCell = [[NSTextAttachmentCell alloc] initImageCell:emoticon]; NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; [attachment setAttachmentCell: attachmentCell ]; NSAttributedString *attributedString = [NSAttributedString attributedStringWithAttachment: attachment]; [allstring insertAttributedString:attributedString atIndex:1];