Localization UI分段控制和定位

Localization UI分段控制和定位,localization,ios6,uisegmentedcontrol,Localization,Ios6,Uisegmentedcontrol,我有一个.xib文件,附带不同语言的.strings文件。.xib文件包含一个标签和一个UISegmentedControl 当要求IB本地化.xib文件时,我得到以下.strings文件: "6.segmentTitles[0]" = "title1"; // ...More strings related to the segmented control... "11.text" = "bla"; “bla”字符串属于标签 更改“bla”字符串会反映在运行时中,而更改“title1”字符串

我有一个
.xib
文件,附带不同语言的
.strings
文件。
.xib
文件包含一个标签和一个
UISegmentedControl

当要求IB本地化
.xib
文件时,我得到以下
.strings
文件:

"6.segmentTitles[0]" = "title1";
// ...More strings related to the segmented control...
"11.text" = "bla";
“bla”字符串属于标签


更改“bla”字符串会反映在运行时中,而更改“title1”字符串则不会。有人知道为什么吗?

这个问题并不新鲜,但由于它仍然没有任何答案,我将添加我的解决方案,因为它可能会帮助其他人

一般来说,如上所述,UISegmentedControl段标题不拾取本地化字符串是一个开放性错误

- (void)viewDidLoad
{
    ...

    // Locale will be picked automatically by NSBundle.
    NSString *resourcePath  =[[NSBundle mainBundle] pathForResource:@"MainStoryboard" ofType:@"strings"];
    NSDictionary *resourceDict = [NSDictionary dictionaryWithContentsOfFile:resourcePath];
    [self.segmentedControl setTitle:[resourceDict objectForKey:@"COo-BO-Ryl.segmentTitles[0]"] forSegmentAtIndex:0];
    [self.segmentedControl setTitle:[resourceDict objectForKey:@"COo-BO-Ryl.segmentTitles[1]"] forSegmentAtIndex:1];

}
其中,
COo BO Ryl
是segmentedControl的对象ID


不太漂亮,但能完成任务。

有这个,但还没有被检测出来。9年后,这个错误仍然存在。在他的代码中,OP使用了xib版本,在我的代码中,我使用了故事板版本,但除此之外,解决方案应该可以工作。