Using an internal URL scheme with a UIWebView to modify a UILabel

I have a UIWebView that shows a couple of screens in a UINavigationController:

First View > Second View > View with UIWebView + UILabel

Now I am showing a specific page in this web view that has a link to my application ....

myapp://foofoo

I know that you can customize your own URL with (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)urland some info.plist, but how to change the UILabel, which is one of the same screens as the UIWebView, just by clicking the link myapp: // foofoo?

+3
source share
2 answers

- , UIWebView -webView: shouldStartLoadWithRequest: navigationType: . , , , .

UIWebView Expose Objective C JavaScript

+4
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSLog(@"scheme = %@",[[request URL] scheme]);

    if([[[request URL] scheme]isEqualToString:@"myscheme"])
    {
        [messageLabel setText:@"HELLO!"];
        return NO;
    }
    else return YES;
}

, UIWebViewDelegate, .

+4

Source: https://habr.com/ru/post/1786754/


All Articles