Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!