How to use UIWebView's delegates?

I want to get to know when the UIWebView did finish loading its website but I cannot find a delegate connector in the Interface Builder. That’s why I connected all other delegates, one by one, though they don’t seem right (downloadDelegate, frameLoadDelegate, policyDelegate, resourceLoadDelegate, UIDelegate) but my following delegate methods of my script aren’t called anyway:


	on webView_shouldStartLoadWithRequest_navigationType_(a, b, c)
		display dialog "1"
	end webView_shouldStartLoadWithRequest_navigationType_
	
	on webViewDidStartLoad_(a)
		display dialog "2"
	end webViewDidStartLoad_
	
	on webViewDidFinishLoad_(a)
		display dialog "3"
	end webViewDidFinishLoad_
	
	on webView_didFailLoadWithError_(a, b)
		display dialog "4"
	end webView_didFailLoadWithError_

see: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html

I even found that UIWebView has a delegate property. But I cannot call it’s setter as then the log tells me that its setter doesn’t exist.

Has anyone experience with that? Thank you for your hints!

Hi,

of course the web view has a delegate outlet to connect in Interface Builder.
Make sure that you have highlighted the proper UI element (not the parent UIView)

If the web view and the delegate are in the same .xib class file
connect the delegate in Interface Builder with the class
or programmatically add an outlet property UIWebView *webView and set the delegate with


self.webView.delegate = self;

EDIT: I strongly doubt that iOS speaks AppleScriptObjC :wink:

Dear Stefan,

you helped me again: I was looking at the wrong page, I have to implement these methods, in my case I am using the frameLoadDelegate (UIWebView doesn’t have a pure “delegate”).

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Protocols/WebFrameLoadDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40003828

Thank you very much!