我正在尝试构建一个应用程序,我可以让用户自由添加emojis,就像在GTalk中一样(例如:P :) :( ...)。但是,一旦用户输入了字符,我无法确定处理和显示它们的确切方法。
请注意相同的想法,因为任何形式的帮助都可能触发解决方案。
答案 0 :(得分:2)
对于输入,您可以使用自定义按钮,使用表情符号的unicode表示设置其标题。 Iphone原生支持。
[myButton setTitle:@"\ue415" forState:UIControlStateNormal];
要在文本框中显示它,您必须将其作为字符串的单个字符处理,以便您可以将常规文本与表情符号连接。
此页面列出了完整的表情符号列表:http://pukupi.com/post/1964/
修改:您可以使用转化表
:) = \ ue415 :( = \ ue40e ....
您可以使用该转换表使用图像而不是unicode字符,但如果要在同一段落中合并文本和图像,则会非常复杂。 以下是使用属性列表的示例,如果要使用图像
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SparkSetVersion</key>
<integer>1</integer>
<key>Emoticons</key>
<dict>
<key>angry.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>>:o</string>
<string>>:-o</string>
<string>>:O</string>
<string>>:-O</string>
<string></string>
</array>
<key>Name</key>
<string>Angry</string>
</dict>
<key>blush.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-[</string>
</array>
<key>Name</key>
<string>Blush</string>
</dict>
<key>confused.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>?:|</string>
</array>
<key>Name</key>
<string>Confused</string>
</dict>
<key>cool.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>B-)</string>
</array>
<key>Name</key>
<string>Cool</string>
</dict>
<key>cry.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:'(</string>
<string></string>
</array>
<key>Name</key>
<string>Cry</string>
</dict>
<key>devil.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>]:)</string>
</array>
<key>Name</key>
<string>Devil</string>
</dict>
<key>grin.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-D</string>
<string>:D</string>
<string></string>
</array>
<key>Name</key>
<string>Grin</string>
</dict>
<key>happy.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-)</string>
</array>
<key>Name</key>
<string>Happy</string>
</dict>
<key>laugh.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:^0</string>
</array>
<key>Name</key>
<string>Laugh</string>
</dict>
<key>love.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:x</string>
</array>
<key>Name</key>
<string>Love</string>
</dict>
<key>mischief.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;\</string>
</array>
<key>Name</key>
<string>Mischief</string>
</dict>
<key>mischief.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;\</string>
</array>
<key>Name</key>
<string>Mischief</string>
</dict>
<key>sad.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-(</string>
<string>:(</string>
<string></string>
</array>
<key>Name</key>
<string>Sad</string>
</dict>
<key>smile.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-)</string>
<string>:)</string>
<string></string>
</array>
<key>Name</key>
<string>Smile</string>
</dict>
<key>silly.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-p</string>
<string>:-P</string>
<string>:P</string>
<string>:p</string>
<string></string>
</array>
<key>Name</key>
<string>Tongue</string>
</dict>
<key>cool.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>8-)</string>
<string></string>
</array>
<key>Name</key>
<string>Cool</string>
</dict>
<key>wink.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;-)</string>
<string>;)</string>
<string></string>
</array>
<key>Name</key>
<string>Wink</string>
</dict>
</dict>
</dict>
</plist>