简体   繁体   中英

How do I specify a multiline title in an iOS Settings bundle?

I have added a Settings.bundle to my iOS application. One of my settings is a toggle switch with a long title. This title is getting truncated.

I have tried:

  1. "My Superlong\\nTitle"
  2. "My Superlong 
 Title"

but neither worked: \\n and &#xA were displayed as part of the Title. Is it possible to have a line break/newline in my title? Thanks!

Yes , you can add a line return in a group title or footer:

  1. Add a new row of type Group in your Settings.bundle file
  2. Insert a new row in that group
  3. Set key name to FooterText (not available in drop down list)
  4. Set value to your long text
  5. Open Root.plist as source code (right click, Open As...)
  6. Insert 
 where a line return is needed

No , you cannot add a line return in labels attached to controls (text field, toggle switche, slider). If text is too long it's simply truncated with ellipsis… This is why you should have a very short label (for iPhone in portrait) then you can add a long description below the control using a group footer as explained above.

No, you have very little control over the Settings.bundle and a multiline title is not an option. Best thing to do would be to cut down the cell title and create a group title, or group footer.

在此输入图像描述

I had voted @riobidon 's answer. However, I found out that 
 won't work in localization.

If you need localization, here is what you should do.

In Root.plist , use some words for place holding. For example, use "footer text" for a group footer.

Then in localization, do as below.

In en.lproj/Root.strings , add

"footer text" = "the real footer you want.\nSome other descriptions";

You can use \\n in the localization.

In other languages' localization, you can do the same. No one will see "footer text", as English is the default deployment language. A user either sees what the language that you have localized, or the English as failed safe.

我通过在包含切换开关的组中添加FooterText来解决此问题

Have you tried:

Top
Bottom

just to see if it works with a short String? I think that there's a character limit for Titles and a line break would count towards that character limit.

You can not line break your Title, iOS OS limits the characters that can be displayed under the App's Icon. An example is "Where's My Water?", even though its official Title is "Where's Mr Water?" its appears as "Water?" under the App Icon

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM