多个 UIWebView 问题
我真的不擅长这些协议,特别是因为这确实是我第一次使用它们。我在同一视图中有两个 UIWebView:webView 和 webView2。如何更改这行代码以适用于 webView2?
-(void)webViewDidStartLoad:(UIWebView *)webView {
我尝试将“webView”更改为“webView2”,但 Xcode 说我有两次相同的行,所以显然这是行不通的。我应该怎么办?感谢您的帮助!
顺便说一句,我想我必须在这里添加一个 IF 语句,但它应该是什么?
I'm really not good with these protocols, especially because this is really my first time using them. I have two UIWebViews in the same view: webView and webView2. How do I change this line of code to work for webView2?
-(void)webViewDidStartLoad:(UIWebView *)webView {
I tried changing "webView" to "webView2", but Xcode said that I had the same line twice, so obviously this won't work. What should I do? Thanks for your help!
Btw, I'm thinking I have to add an IF statement within here, but what should it be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正是出于这个原因,委托方法传入一个参数来定义它来自哪个 Web 视图。
The delegate method passes in a parameter defining which web view it’s coming from for exactly this reason.
那么同样的方法将会被调用,但是传入了 webview 的 ref,
因此,您可以在委托中保留对两个 webview 的引用,并说出类似 if(webview1==webview) 的内容,只有当委托方法中传递的 webview 引用是 webview1 时,它才会评估为 yes,这样您就可以找出正在调用哪个 webview使用 if 语句的委托
Well the same method will be called, but the ref of the webview is passed in,
So you can keep a reference to both your webviews in your delegate and say something like if(webview1==webview) which will evaluate to yes only if the webview ref passed in the delegate method is webview1 so you can figure out which webview is calling the delegate using the if statement
我想你想要:
希望有帮助!
I think you want:
Hope that Helps!