Read-Only string in settings bundle

2020-03-02 04:51发布

问题:

I've added a Settings.bundle, however while displaying version numbers I'd like the fields to be read-only.

I've seen a few suggestions that say to change the type from text to title, but when I do this, the settings entry isn't displayed.

回答1:

        <array>    
            <dict>
                <key>Type</key>
                <string>PSGroupSpecifier</string>
                <key>Title</key>
                <string>version</string>
            </dict>
            <dict>
                <key>DefaultValue</key>
                <string>1.1</string>
                <key>Key</key>
                <string>version</string>
                <key>Title</key>
                <string>version</string>
                <key>Type</key>
                <string>PSTitleValueSpecifier</string>
            </dict>
        </array>

I am able to add readonly variable 'Version' with the above dictionary in root.plist. Have you set using Title specifier ?? Or Try adding above dict. in your root.plist , this will add readonly title in your settings in group style.



回答2:

To display Title property in the Settings.bundle you need also to add "Default Value" (it could be empty).

Check the answer here: https://stackoverflow.com/a/22712746/1757229



回答3:

you need to change your type from PSTextFieldSpecifier to PSTitleValueSpecifier.