我最近一直在开发一个使用自由形式 View Controller 的应用程序。一切都很好,直到我想考虑本地化设置按钮标题标签的文本。
我尝试以多种方式设置文本,但似乎没有任何效果。起初我使用 Storyboard ID 从 Storyboard实例化 View Controller ,如下所示:
self.dropDown = [self.storyboard instantiateViewControllerWithIdentifier:@"dropDown"];
但后来我意识到我无法设置 Controller 的标题。或者至少我不知道在哪里设置它们。我将它们全部作为属性通过 Storyboard 连接起来。我试图在 DropDown.m 类的 viewDidLoad 方法中设置按钮的标题,没有。我还尝试在 Controller 中设置标题,如下所示:
[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];
关于ios - 呈现一个自由形式的 View Controller 并设置其标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25867400/