在 iPhone SDK 中通过短信和电子邮件发送 ASCII Art 时对齐不正确
在我的 iPhone 应用程序中,我有 ASCII 艺术作品,我通过电子邮件和短信分享。
我已将 ASCII 艺术以及换行符和空格插入到 Sqlite 数据库中。
问题是当我通过短信和电子邮件发送它们时,整个 ASCII 艺术都是左对齐的,并且字符之间的间距丢失了。
在我的应用程序中的标签中提取的 ASCII 艺术如下
插入到电子邮件 API (MFMailComposeViewController) 时相同的 ASCII 艺术如下下面
插入 SMS API (MFMessageComposeViewController) 时的相同 ASCII 艺术如下
如何维护空格?如何使 ASCII 艺术在邮件和 SMS API 视图中看起来正确?
In my iPhone app, I have ASCII art, which I am sharing via email and SMS.
I have inserted the ASCII art into the Sqlite database along with the newline character and spaces.
Problem is when I send them through SMS and Email, the whole ASCII art comes in left alignment and spacing between characters is lost.
ASCII Art fetched in Label in my app is as below
Same ASCII Art when inserted to Email API (MFMailComposeViewController) is as below
Same ASCII Art when inserted to SMS API (MFMessageComposeViewController) is as below
How to maintain the spaces? How to make the ASCII art look proper in Mail as well as SMS API View?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许是字体的原因。如果您在应用程序中使用 courier new,那么每个空格都会像普通字符一样具有相同的间隙,但在其他字体中它们并不相同。您可以尝试将每个空格替换为双倍空格,也许它会再次看起来不错。
您可以将 html 设置为
MFMailComposeViewController
,以便强制使用空格,您可以使用' '
或' '
代替' '
另外,在显示 Composer 视图之前,您可以更改属性以显示 html (
[mailComposer setMessageBody:myHtmlString isHTML:YES];
),其中myHtmlString< /code> 表示这一点:
要扩展我的第二个建议,请将每个空格替换为双倍空格:
Maybe it's because of the font. If you use in your App courier new then each space would have the same gap like a normal character but in other fonts they are not the same. You can try and replace each space with double space perhaps it will look nice again.
You can set html to your
MFMailComposeViewController
so to force spaces you can use' '
or' '
instead of' '
Also, before showing your composer view you can change an attribute to display html (
[mailComposer setMessageBody:myHtmlString isHTML:YES];
) wheremyHtmlString
represent this:To expand on my second advice, replace each space with double space: