将“标题字符串"设置为"Settings Bundle iOS" [英] Set Title String to Settings Bundle iOS

查看:72
本文介绍了将“标题字符串"设置为"Settings Bundle iOS"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据iphone设置语言/用户偏好的语言动态地本地化设置屏幕文本.在我的情况下,本地化文本是从服务器获取的.我将文本存储在数据库中并将其显示在屏幕上.设置屏幕应根据用户偏好的语言/设备语言进行本地化.我试图访问Root.plist中某个项目的标题字符串.但是它返回值,但是我需要标题.如何访问/更改项目标题.

I need to localize my setting screen text dynamically based on the iphone setting language/user preferred language. In my scenario, localized text are fetching from the server. I am storing text in database and showing it on the screen. Setting screen should be localized based on the user preferred language/device language. I tried to access the title string of an Item in Root.plist. But it returns value but i need title. How can i access/change the title of the item.

例如:

{
        DefaultValue = 1;
        Key = "enabled_preference";
        Title = "Keep me logged in";
        Type = PSToggleSwitchSpecifier;
    }

[[NSUserDefaults standardUserDefaults]valueForKey:@"enabled_preference"]; 

其返回值为1,但我需要更改标题为保持登录状态".

which return the value as 1 but i need the title "Keep me logged in" which needs to be changed.

我需要对"Title"进行本地化(即)而不是使用.lproj文件,因为我在词典中设置了一组本地化字符串.我需要使用字典中的值设置标题.

i need a "Title" to be localized (ie) instead of using .lproj file, i have set of localized strings in a dictionary. i need to the set the title with value from dictionary.

我该怎么做.

谢谢

推荐答案

这里是一种获取所有值和键的方法.

Here is a way where you can get all the values and keys.

这可能会为您提供帮助,获取所有密钥并遍历每个人以获取您正在寻找的密钥

This might help you, get all the keys and traverse everyone to get the key you are looking for

所有值:

NSLog(@"%@", [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allValues]);

所有键:

NSLog(@"%@", [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys]);

所有键和值:

NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);

用于:

NSArray *keys = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys];

for(NSString* key in keys){
// your code here
NSLog(@"value: %@ forKey: %@",[[NSUserDefaults standardUserDefaults] valueForKey:key],key);
}  

这篇关于将“标题字符串"设置为"Settings Bundle iOS"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆