根据县动态iPhone更改货币符号? [英] Change currency symbol based on county dynamically iPhone?

查看:247
本文介绍了根据县动态iPhone更改货币符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据用户的本地化来更改iPhone应用中的货币符号。如果我的应用程序在美国工作,我需要更改货币符号$。如果应用程序在Eroupe国家工作,我们需要将符号更改为€,如果应用程序在日本,则应将符号更改为¥,如果应用程序在澳大利亚运行,则该符号应位于 $。通过这种方式,如果应用程序在任何国家/地区运行,应用程序应根据本地化来更改货币符号。我使用下面的代码,但它始终显示在$。我该如何解决?还有怎么测试呢?请帮助我。

I want to change the currency symbols in iPhone app based on user's localization. If my app is working in US i need to change the currency symbol "$". If the app is working in Eroupe countries, we need to change the symbol to "€", if the app is in Japan, the symbol should be change to "¥" and if the app is running in Australia the symbol should be in "$". By this way if the app is running in any country the app should be change the currency sign based on the localizations. I have used this below code but, it always shows in "$". How can i solve this? And also how can i test this? Please help me.

NSNumberFormatter *currencyFormat = [[NSNumberFormatter alloc] init];
NSLocale *locale = [NSLocale currentLocale];
[currencyFormat setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormat setLocale:locale];
NSLog(@"Amount with symbol: %@", [currencyFormat stringFromNumber:@"10.00"]); 

请帮助我。我错了什么?感谢提前。

Please help me. Where i am wrong? Thanks in advance.

推荐答案

模拟器支持更改本地化,就像常规设备一样。确保您在启动应用程序之前更改它,并显示正确的格式。

The simulator has support for changing localizations, just like on a regular device. Make sure that you change that before starting your app and it should show the correct format.

要更改区域设置(在模拟器上):

启动模拟器(通过启动应用程序),按 Home 按钮,转到设置一般国际,然后选择您要测试的区域格式完成后关闭模拟器并重新启动应用程序。区域设置已更改,因此您应该看到在显示的货币符号中。

To change the locale (on the simulator):
Start the simulator (by starting your app), press the Home button, go to Settings, General, International and then choose the Region Format you want to test. Close the simulator after it's done and restart your app. The locale has changed so you should see that in the currency symbol that is shown.

在实际设备上,您将遵循相同的路由来更改区域设置。

On real devices you follow the same route to change the locale.

这篇关于根据县动态iPhone更改货币符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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