Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
How to close WKWebView via javascript on the site?

I have a finished application. I can not implement the closure of VKWebView from registration at the end of registration. Since I have not encountered this in the lens - p.

WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];

        WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
        webView.navigationDelegate = self;
        webView.customUserAgent = "Cron";
        [self.view addSubview:webView];

        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://myUrl"]];
        [webView loadRequest:request];
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

in order to interact with the WKWebView, you can use the javascript functions for them.

After the WKWebView has finished loading (via delegate for example), yo can use the evaluateJavascript functions, to trigger any event in the web or in your iOS code.

For example:

[self.webview evaluateJavaScript:@"var foo = 1; foo + 1;" completionHandler:^(id result, NSError *error) {
    if (error == nil)
    {
        if (result != nil)
        {
            NSInteger integerResult = [result integerValue]; // 2
            NSLog(@"result: %d", integerResult);
        }
    }
    else
    {
        NSLog(@"evaluateJavaScript error : %@", error.localizedDescription);
    }
}];

The javascript function is:

var foo = 1; foo + 1;

There you can set any javascript function from objective-c side, or call any function in the web side.

For example, if you have a javascript function in your web site called:

func closeWeb()

You have to set the function like this:

[self.webview evaluateJavaScript:@"closeWeb();" completionHandler:^(id result, NSError *error) {
    if (error == nil)
       // Code for success
    } else {
        NSLog(@"evaluateJavaScript error : %@", error.localizedDescription);
    }
}];
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda