作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已将丹麦语本地化添加到我的 iOS 8 项目中。我想本地化静态 UITableViewSection
的页眉和页脚,我面临的问题是页眉已本地化,但页脚始终包含来自 Main.strings(英语)文件的字符串。这些值是通过 Interface Builder 设置的。我已经在设备和模拟器上对此进行了测试。
Main.strings(英文)
/* Class = "UITableViewSection"; footerTitle = "..."; ObjectID = "cHU-BB-3aF"; */
"cHU-BB-3aF.footerTitle" = "Footer Title";
/* Class = "UITableViewSection"; headerTitle = "Payment Details"; ObjectID = "cHU-BB-3aF"; */
"cHU-BB-3aF.headerTitle" = "Header Title";
Main.strings(丹麦语)
/* Class = "UITableViewSection"; footerTitle = "..."; ObjectID = "cHU-BB-3aF";*/
"cHU-BB-3aF.footerTitle" = "Localized Footer Title"; // this does not work
/* Class = "UITableViewSection"; headerTitle = "Payment Details"; ObjectID = "cHU-BB-3aF"; */
"cHU-BB-3aF.headerTitle" = "Localized Header Title"; // this works
最佳答案
您可以在代码中设置页脚的标题并改用 NSLocalizedString
。要在代码中设置页脚的标题,您应该实现 tableView:viewForFooterInSection:
。所以,它看起来像这样:
override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let footerLabel = UILabel(frame: CGRect.zeroRect)
footerLabel.text = NSLocalizedString("Your title for footer", comment: "Comment for footer")
footerLabel.sizeToFit()
return footerLabel
}
然后您可以在终端中使用genstrings
命令创建一个Localizable.strings 文件:
genstrings *.swift -o en.lproj
您可以通过在项目导航器中选择它,在实用程序中选择文件检查器,然后选中丹麦语来添加丹麦语的 Localizable.strings 文件的本地化。
关于ios - UITableViewSection footerTitle 未本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31248210/
我已将丹麦语本地化添加到我的 iOS 8 项目中。我想本地化静态 UITableViewSection 的页眉和页脚,我面临的问题是页眉已本地化,但页脚始终包含来自 Main.strings(英语)文
我是一名优秀的程序员,十分优秀!