在 xcode 中实现表情符号

发布于 2024-11-01 05:05:55 字数 129 浏览 6 评论 0原文

我正在尝试构建一个应用程序,让用户可以像 GTalk 一样自由添加表情符号(例如:P :) :( ...)。但我无法弄清楚用户输入字符后处理和显示它们的确切方法。

请提出同样的想法,因为任何形式的帮助都可以触发此问题的解决方案。

I am tryingt o build an application where I am giving user liberty to add the emojis as in GTalk (e.g. :P :) :( ...). But I am not able to figure out the exact way to handle and display them once the characters are entered by the user.

Kindly pour in ideas for the same, as any form of help could trigger a solution for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月如刀 2024-11-08 05:05:55

对于输入,您可以使用自定义按钮,使用表情符号的 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>

For inputs you can use custom buttons, setting their titles with the unicode representation of the emojis. Iphone has native support for this.

[myButton setTitle:@"\ue415" forState:UIControlStateNormal];

For display it in a textbox you have to handle this as a single char of a string so you can concatenate your regular text with emojis.

A complete list of emojis are listed in this page: http://pukupi.com/post/1964/

Edit: You can use a conversion table

:) = \ue415
:( = \ue40e
....

You can use that conversion table with using images instead unicode chars but it is very complicated if you want to merge text and images in the same paragraph.
Here is an example using a property list if you want to use images

<?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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文