小编Eti*_*nne的帖子

列出所有区域设置标识符和相应的区域文本 Swiftui

我想生成一个所有区域设置标识符的列表,供用户选择作为默认值。类似于在标准设置中选择区域。

因此,我想生成一个列表,其中包含例如“澳大利亚”、“奥地利”、“阿塞拜疆”、...、“也门”、“赞比亚”、“津巴布韦”。如果用户选择“澳大利亚”,我想返回en_AU.

所以需要确定下Locale可以使用的属性以及如何遍历它。

目前,只是想看看我是否可以返回文本,例如“澳大利亚”:

Text(Locale.localizedString(Locale.init(identifier: Locale.availableIdentifiers[0].description)))
Run Code Online (Sandbox Code Playgroud)

但是返回错误:

Closure containing control flow statement cannot be used with function builder 'ViewBuilder'
Run Code Online (Sandbox Code Playgroud)

谢谢

locale region swift swiftui

5
推荐指数
1
解决办法
139
查看次数

标签 统计

locale ×1

region ×1

swift ×1

swiftui ×1