iOS:如何将可滚动文本视图添加到应用程序首选项?

发布于 2024-11-25 06:03:20 字数 85 浏览 2 评论 0原文

我需要将可滚动文本视图添加到我的应用程序首选项中,例如苹果自己的法律页面(查看“设置”->“常规”->“关于”->“法律”)。我该怎么做?

I need to add scrollable text view to my application preferences, like Apple's own legal page (look at Settings->General->About->Legal). How do I do it?

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

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

发布评论

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

评论(3

情未る 2024-12-02 06:03:20

我找到了一个可以完成这项工作的解决方法。将需要显示的长文本拆分为一组或多个段落,每个不超过 500 字节(我不确定确切的数字,但如果 PSGroupSpecifier 中的标题文本太长,iOS 将不会显示任何内容)。然后为每个段落创建具有单独 PSGroupSpecifier 元素的 Legal.plist:

<dict>
<key>DoNotLocalize</key>
<string>YES</string>
<key>Title</key>
<string>Paragraph of boring text blah blah blah</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>

然后将其显示为子窗格。宾果游戏 - 你有一个文本滚动条!

I found a workaround which does the job. Split long text you need to display into a set or paragraphs, each no longer than 500 bytes (I'm not sure about exact number, but if Title text in PSGroupSpecifier is too long, iOS won't display anything). Then create Legal.plist with separate PSGroupSpecifier element for each paragraph:

<dict>
<key>DoNotLocalize</key>
<string>YES</string>
<key>Title</key>
<string>Paragraph of boring text blah blah blah</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>

and then show it as a child pane. Bingo - you have a text scroller!

忘羡 2024-12-02 06:03:20

使用 PSGroupSpecifier,将所需的文本设置为标题。
请注意,您可以拥有的文本量是有限的,因此您需要使用多个组说明符。
(据我所知,每组的限制是 500 个字符)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>StringsTable</key>
  <string>Tos</string>
  <key>PreferenceSpecifiers</key>
  <array>
    <dict>
      <key>Type</key>
      <string>PSGroupSpecifier</string>
      <key>Title</key>
      <string>long, localizable, text!</string>
    </dict>   
  </array>
</dict>
</plist>

Use a PSGroupSpecifier, setting the text you need as Title.
Observe that there is a limit to the amount of text you can have so you would need to use multiple group specifiers.
(as far as I can see, the limit is in the region of 500 chars per group)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>StringsTable</key>
  <string>Tos</string>
  <key>PreferenceSpecifiers</key>
  <array>
    <dict>
      <key>Type</key>
      <string>PSGroupSpecifier</string>
      <key>Title</key>
      <string>long, localizable, text!</string>
    </dict>   
  </array>
</dict>
</plist>
忘你却要生生世世 2024-12-02 06:03:20

您的一种选择是使用 UITextView

UITextView 类实现可滚动的多行文本区域的行为。该类支持使用自定义字体、颜色和对齐方式显示文本,并且还支持文本编辑。您通常使用文本视图来显示多行文本,例如在显示大型文本文档的正文时。

如果要显示富文本,可以通过将自己的 HTML(存储为资源文件)加载到 UIWebView

One option you have is using UITextView:

The UITextView class implements the behavior for a scrollable, multiline text region. The class supports the display of text using a custom font, color, and alignment and also supports text editing. You typically use a text view to display multiple lines of text, such as when displaying the body of a large text document.

If you want to display a rich text, you can do that by loading your own HTML (stored as a resource file) into a UIWebView.

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