如何在iPhone中刷新NSLocale? [英] How to refresh the NSLocale in iPhone?

查看:176
本文介绍了如何在iPhone中刷新NSLocale?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用iPhone应用程序,使用NSLocale可以使当前的货币符号正常工作,但是当我按下主屏幕按钮时,该应用程序进入后台进程并更改了货币(设置>>国际>> ​​Regionformat >>美国,印度等...),然后从后台打开该应用程序,货币符号未更改,但是我导航到另一个屏幕,然后转到上一个屏幕,仅更改了货币,但是当我从后台打开应用程序时,我想要,然后货币符号会自动更改.如何解决这个问题?我需要你的帮助

I am currently working in iPhone application, Using NSLocale to get the current Currency symbol working fine, but when i press home button the app goes to background process and i change the Currency (Setting>>International>>Regionformat>>Like United states,India etc...) in this way, then open that application from background the currency symbol not changed, but i navigate to another screen then comes to previous screen only currency changed, but i want when i open the application from background, then currency symbol changed automatically. How to fix this? I need your help

谢谢

我在这里尝试过代码:

NSLocale *theLocale = [NSLocale currentLocale];
Getdollarsymbol = [theLocale objectForKey:NSLocaleCurrencySymbol];
NSString *Code = [theLocale objectForKey:NSLocaleCurrencyCode];

推荐答案

请尝试以下代码.让我知道这是否有效,

Please try this code. And let me know if this is working,

-viewDidLoad:添加行中:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshCurrencySymbol) name:NSCurrentLocaleDidChangeNotification object:nil];

然后:

-(void) refreshCurrencySymbol
{ 
    NSLocale *theLocale = [NSLocale currentLocale];
    NSString *symbol = [theLocale objectForKey:NSLocaleCurrencySymbol];
    NSLog(@"Symbol : %@",symbol);
    NSString *code = [theLocale objectForKey:NSLocaleCurrencyCode];
    NSLog(@"Code : %@",code);
}

谢谢.

这篇关于如何在iPhone中刷新NSLocale?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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