简体   繁体   English

单击uiwebview中的链接,打开一个弹出窗口

[英]open a pop up on click of a link in uiwebview

I have uiwebview which loads a url. 我有uiwebview加载一个URL。 When user clicks on any link I want to open a popup window. 当用户单击任何链接时,我想打开一个弹出窗口。 I know I can detect link click by using following delegate method: 我知道我可以使用以下委托方法检测链接点击:

-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

But the problem is that above delegate method is also being called when the viewcontroller is loaded. 但是问题在于,加载视图控制器时,还会调用上述委托方法。 So the popup is generated on view load but it should open later when the link is clicked. 因此,弹出窗口是在视图加载时生成的,但是当单击链接时应在以后打开。 I hope my problem is clear. 我希望我的问题很清楚。

Regards 问候
Pankaj 潘卡伊

-(void)webViewDidStartLoad:(UIWebView *)webView   //WebUI
{
    NSLog(@"Web Page start loading.(Empty)");
}

This method called when a page start loading initially, So you can take advantage of it. 最初在页面开始加载时调用此方法,因此您可以利用它。 This will call when user click a link, as it will try to load a page. 用户单击链接时将调用此方法,因为它将尝试加载页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM