The question sounds weird, but here is my case.
I have a UIWebView
in my UIView
( done by [self.view addSubview:webView];
) which occupies full screen. It intentionally hides the UIView
before the UIWebView
clicks on an action javascript:window.close();
.
How do I associate JavaScript in UIWebView
page to UIView
's action , e.g. [webView removeFromSuperView];
?
The question sounds weird, but here is my case.
I have a UIWebView
in my UIView
( done by [self.view addSubview:webView];
) which occupies full screen. It intentionally hides the UIView
before the UIWebView
clicks on an action javascript:window.close();
.
How do I associate JavaScript in UIWebView
page to UIView
's action , e.g. [webView removeFromSuperView];
?
1 Answer
Reset to default 7This is possible:
Set the location to something with your own scheme in the url, i.e.
document.location.href = "myscheme://DoSomething"
This will cause the UIWebViewDelegate method shouldStartLoadWithRequest: to be called with an NSURLRequest parameter whose scheme is"myscheme". So you look for this scheme and extract the DoSomething and then act on the DoSomething, which in your case would be to call remove from superView.
(In the UIWebView dealloc probably need to make sure you call stopLoading)