Ios 显示自由形式的viewcontroller并设置其标签

Ios 显示自由形式的viewcontroller并设置其标签,ios,viewcontroller,Ios,Viewcontroller,我最近开发了一个应用程序,它使用自由形式的视图控制器。一切都很好,直到我想设置按钮标题标签的文字考虑本地化 [self.dropDown.priceAscendingButton setTitle:NSLocalizedString(@"priceAscending", nil) forState:UIControlStateNormal]; 我试图以多种方式设置文本,但似乎没有任何效果。首先,我使用其storyboard ID从storyboard实例化视图控制器,如下所示: sel

我最近开发了一个应用程序,它使用自由形式的视图控制器。一切都很好,直到我想设置按钮标题标签的文字考虑本地化

[self.dropDown.priceAscendingButton setTitle:NSLocalizedString(@"priceAscending", nil) forState:UIControlStateNormal];
我试图以多种方式设置文本,但似乎没有任何效果。首先,我使用其storyboard ID从storyboard实例化视图控制器,如下所示:

    self.dropDown = [self.storyboard instantiateViewControllerWithIdentifier:@"dropDown"];
[self.dropDown.priceAscendingButton setTitle:NSLocalizedString(@"priceAscending", nil) forState:UIControlStateNormal];
但后来我意识到我不能设置控制器的标题。或者至少我不知道把它们放在哪里。我把它们都作为属性通过故事板连接起来。我试图在DropDown.m类的viewDidLoad方法中设置按钮的标题,没有。我还尝试在控制器中设置标题,在这里我显示下拉列表,如下所示:

    [self.dropDown.priceAscendingButton.titleLabel setText:NSLocalizedString(@"priceAscending", nil)];
    [self.dropDown.priceDescendingButton.titleLabel setText:NSLocalizedString(@"priceDescending", nil)];
    [self.dropDown.dateAscendingButton.titleLabel setText:NSLocalizedString(@"dateAscending", nil)];
    [self.dropDown.dateDescendingButton.titleLabel setText:NSLocalizedString(@"dateDescending", nil)];
[self.dropDown.priceAscendingButton setTitle:NSLocalizedString(@"priceAscending", nil) forState:UIControlStateNormal];
但是什么都没用

[self.dropDown.priceAscendingButton setTitle:NSLocalizedString(@"priceAscending", nil) forState:UIControlStateNormal];
你能帮我吗?

用这个

[self.dropDown.priceAscendingButton setTitle:NSLocalizedString(@"priceAscending", nil) forState:UIControlStateNormal];