如何更改UIAlertView的语言以匹配设备语言?

Fre*_*ght 1 iphone sdk localization uialertview ios

我的应用程序有一个localizable.strings文件,支持英语,法语和德语.我点击一个按钮时弹出一个警报视图,那么如何使这个警报视图的语言与设备设置的语言相匹配?任何帮助将不胜感激.

Anu*_*yal 14

与应用程序中的任何其他本地化字符串一样,将UIAlertView消息,标题和按钮标题本地化在Localizable.strings文件中.

看这个例子:

UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Connection Error", nil) message:NSLocalizedString(@"Couldn't connect to the internet. Please check your network connection", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Ok", nil) otherButtonTitles:nil, nil];
Run Code Online (Sandbox Code Playgroud)