开发中的生活程序员iOS 开发

应用程序国际化语言的转换

2016-05-18  本文已影响108人  没有名字就是我的名字

应用程序国际化语言的转换####


更改语言的简单示例#####
第一张是主界面######
Snip20160518_2.png
点击中文之后再点击屏幕######
Snip20160518_5.png
点击英文之后再点击屏幕######
Snip20160518_6.png

首先,要从storyboard里面创建两个按钮,然后托线

- (IBAction)didClickEn:(id)sender {

self.fileName = @"lan_en";

}
- (IBAction)didClickCh:(id)sender {
self.fileName = @"lan_ch";
}

创建一个点击事件

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
NSString *title = NSLocalizedStringFromTable(@"title", self.fileName, nil);
NSString *message = NSLocalizedStringFromTable(@"message", self.fileName, nil);
NSString *commit = NSLocalizedStringFromTable(@"commit", self.fileName, nil);

***创建一个AlertView***

UIAlertView *alertController = [[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:commit otherButtonTitles:nil, nil];
[alertController show];
}
上一篇 下一篇

猜你喜欢

热点阅读