Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda