Classe NowWebViewController - iOS
. NowWebViewController a classe fornece funções que permitem gerenciar um visualizador da web.
NowWebViewController - loadPage()
Se a solicitação for autenticada, começará a carregar a URL inicial fornecida durante a instanciação usando MakeWebViewController() método.
Se a solicitação falhar na autenticação, o método NowWebViewController(_:didFailNavigationWith:) é chamado no delegado que foi aprovado ao instanciar o objeto.
| Nome | Tipo | Descrição |
|---|---|---|
| Nenhum |
| Tipo | Descrição |
|---|---|
| Nenhum(a) |
O exemplo de código a seguir mostra como chamar esta função.
private func openScreen(_ screen: ArticleListViewModel.Screen) {
switch screen {
case .articleDetail(let sysId):
guard let url = URL(string: "/mesp?id=me_kb_view&sys_kb_id=\(sysId)"), let webViewController = webViewController(for: url) else {
debugPrint("Could not create web view")
return
}
webViewController.loadPage()
navigationController?.pushViewController(webViewController, animated: true)
}
}
NowWebViewController - updateTheme(themeCores: NowWebThemeable)
Atualiza o tema NowWebview com o tema de IU especificado. Use esta função para atualizar o tema de IU da Web depois que ele tiver sido definido inicialmente usando MakeWebViewController() , como ao mudar o tema de claro para escuro.
| Nome | Tipo | Descrição |
|---|---|---|
| ThemeCores | NowWebThemeable | Tema para atualizar a IU da Web. |
| Tipo | Descrição |
|---|---|
| Nenhum(a) |
O exemplo de código a seguir mostra como atualizar um tema de IU leve implementado usando MakeWebViewController() Para o tema de IU escuro usando UpdateTheme() função.
func nowWebViewController(_ nowWebViewController: NowWebViewController, systemThemeDidChange traitCollection: UITraitCollection) {
// The systemThemeDidChange delegate method can be used to call updateTheme() to apply theme changes when the system theme changes.
nowWebViewController.updateTheme(themeColors: traitCollection.userInterfaceStyle == .dark ? DarkNowWebTheme() : LightNowWebTheme())
}