简体   繁体   English

如何调用UIWebview的委托方法?

[英]How to invoke the UIWebview's delegate method?

the Question : 问题:

how to invoke the UIWebview's delegate method 如何调用UIWebview的委托方法

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

Please show me all of the trigger 请向我展示所有触发条件

If you have set your UIWebView to an IBOutlet, you can do this in your viewDidLoad: method: 如果已将UIWebView设置为IBOutlet,则可以在viewDidLoad:方法中执行此操作:

myWebView.delegate = self

Then, whenever anything happens in the web view, your delegate method in your view controller will be called. 然后,无论何时在Web视图中发生任何事情,都将调用视图控制器中的委托方法。

First Step 第一步

@interface ViewController ()<UIWebViewDelegate>

@end

then set Delegate of your UIWebview to self 然后将您的UIWebview Delegate设置为self

self..webview.delegate = self

then implement method you need 然后实现你需要的方法

您可以为webview创建和IBOutlet,并可以像self.webview.delegate=self那样设置它的委托,也可以通过在UI Builder中单击并从UIWebview拖动到视图控制器上的Yellow图标来设置委托。

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

相关问题 如何使用UIWebView Delegate的shouldStartLoadWithRequest方法 - How to use shouldStartLoadWithRequest method of UIWebView Delegate 如何实现UIWebView的默认UIImagePickerController的委托? - How to implement default UIImagePickerController's delegate of an UIWebView? UIwebView的shouldStartLoadWithRequest:委托方法不接收所有加载请求 - UIwebView's shouldStartLoadWithRequest: delegate method Does not Receive all Load Requests NSAssert在uiwebview委托方法中不起作用 - NSAssert not work in uiwebview delegate method 将UIWebView委托迁移到WKWebView委托方法 - Migrating UIWebView delegate to WKWebView delegate method UIWebView错误委托方法与可到达性 - UIWebView Error Delegate Method vs Reachability UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? - UIWebView delegate method shouldStartLoadWithRequest: equivalent in WKWebView? UICollectionViewCell中的UIWebView不调用Delegate方法 - UIWebView inside UICollectionViewCell does not call Delegate Method 我可以在popViewcontroller之后调用委托方法吗? - Can I invoke the delegate method after popViewcontroller? js如何调用UIWebView的方法并获取返回值? - How can js call UIWebView's method and get return value?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM