为 UIWebView 设置委托
如何为我的 UIWebView
设置委托以使用 webViewDidFinishLoad
?
How do I set a delegate for my UIWebView
to use webViewDidFinishLoad
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在接口文件中表明您感兴趣:
然后在您的实现中,您将添加该委托方法:
显然 SomethingController 应该是您的实际控制器,而 UIViewController 是您实际实现的任何内容。
顺便说一句,这基本上就是实现任何委托的方式。
编辑
在基于窗口的应用程序中,假设您的 UIWebView 位于应用程序委托中,您只需将其添加到委托列表中,以逗号分隔,如下所示:
您将包含您的 webViewDidFinishLoad 在应用程序委托的实现中。
编辑 2
最后,您需要将 UIWebView 连接到控制器。通常在 UIViewController 的 viewDidLoad 方法中执行此操作,并使用如下行:
This告诉 UIWebView 应将消息发送到何处。
In the interface file indicate that you're interested:
Then in your implementation you'll add that delegate method:
Obviously SomethingController should be your actual controller, and UIViewController is whatever you're actually implementing.
This, by the way, is basically how you implement any delegate.
Edit
In a window-based app, assuming your UIWebView is in your app delegate, you just add it to the list of delegates, separated by commas, like this:
You'll include your webViewDidFinishLoad in the app delegate's implementation.
Edit 2
Finally, you'll need to connect your UIWebView to your controller. It's common to do this in the
viewDidLoad
method of a UIViewController, with a line like this:This tells the UIWebView where it should send messages.
,按照下面的屏幕截图
连接
inYourViewController.h
后现在您已准备好在
inYourViewController.m
文件中实现委托方法。或者
你可以通过代码做同样的事情。
通过
IBOutlet
连接 webView 与视图控制器后,在inYourViewController.m
文件的viewDidLoad
方法中写入
inYourViewController.h
现在你已经准备好实现webView的委托方法了。谢谢
Follow the screen shot below
after connecting
inYourViewController.h
now you are ready to implement the delegate methods in
inYourViewController.m
file.or
you can do the same thing from code.
After connecting the webView with view controller via
IBOutlet
,IninYourViewController.m
file'sviewDidLoad
Method writeIn
inYourViewController.h
Now you are ready to implement the delegate method of webView.Thanks