gpt4 book ai didi

ios - SFSafariViewController 语言未更新

转载 作者:行者123 更新时间:2023-11-30 11:57:56 42 4
gpt4 key购买 nike

我正在使用 swift 2.0 开发一个项目。该应用程序支持中文和英文两种语言。

我正在使用 SFSafariViewController 打开网址。现在的问题是,当我选择英语时,网址加载成功。但我将语言转换为中文,然后 SFSafariViewController 再次以英语加载相同的网址。

我已经发送了一个带有 url 的新参数来设置浏览器中的语言,但这不起作用。对此有什么建议吗?提前致谢。

编辑:代码

    let language = (Localize.currentLanguage() != "zh-Hans" ? "en" : "zh")
if language == "zh"{
let externalURL = ApiURLs.webViewPath + "/?source=ios&lang=zh-CN"

let safariVC = SFSafariViewController(URL: NSURL(string: externalURL)!)

self.presentViewController(safariVC, animated: true, completion: nil)

}
else
{
let externalURL = ApiURLs.webViewPath + "/?source=ios&lang=en-US"

let safariVC = SFSafariViewController(URL: NSURL(string: externalURL)!)

self.presentViewController(safariVC, animated: true, completion: nil)

}

最佳答案

我猜您创建了错误的网址

请确保您的 ApiURLs.webViewPathhttps://www.iceangelid.net/#/aboutusexternalURL 为下面

let externalURL = ApiURLs.webViewPath + "?source=ios&lang=zh-CN"

如果您打印 externalURL 那么它应该如下所示

https://www.iceangelid.net/#/aboutus?source=ios&lang=zh-CN

我已经测试了下面的代码,它对我来说工作正常,下面的代码适用于 swift4,但导入的是 url

if language == "zh" {
let externalURL = "https://www.iceangelid.net/#/aboutus?source=ios&lang=zh-CN"
let safariVC = SFSafariViewController(url: URL(string: externalURL)! as URL)
self.present(safariVC, animated: true, completion: nil)
}
else {
let externalURL = "https://www.iceangelid.net/#/aboutus?source=ios&lang=en-US"
let safariVC = SFSafariViewController(url: URL(string: externalURL)! as URL)
self.present(safariVC, animated: true, completion: nil)
}

关于ios - SFSafariViewController 语言未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47588574/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com