提供一个自由形式的viewcontroller并设置其标签

时间:2014-09-16 11:19:13

标签: ios viewcontroller

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

我试图以多种方式设置文本,但似乎没有任何工作。起初我使用storyboardID从storyboard实例化视图控制器,如下所示:

    self.dropDown = [self.storyboard instantiateViewControllerWithIdentifier:@"dropDown"];

然后我意识到我无法设置控制器的标题。或者至少我不知道在哪里设置它们。我通过故事板将它们全部连接为属性。我尝试在DropDown.m类的viewDidLoad方法中设置按钮的标题,什么都没有。我还尝试在控制器中设置标题,我就像这样设置dropDown:

    [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)];

但没有任何效果......

你能帮我吗?

1 个答案:

答案 0 :(得分:1)

使用此

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