开发者

UIWebViewDelegate Problems

I have a UIWebView set up in Interface Builder with the delegate set to File's Owner. I have webViewShouldStartLoad, webViewDidFinishLoad, webViewDidStartLoad, and webViewDidFailLoadWithError set up with NSLogs inside to see if they are working. webViewShouldStartLoad works perfectly, but the other three only work on the initial load. if I click a link to go to another page, the other thre开发者_如何学Goe don't work. All the webpages load fine, but I cant get any of the webview delegate functions other than webViewShouldStartLoad to workAnyone have any ideas why this might be?


Is File's Owner the View Controller responsible for the UIWebView?

Make sure it is.

Second, I prefer to set the delegate in code. I takes away any mystery for novice developers. Interface Builder can be unclear at times, especially if you're unsure what the links look like in code. Remember, Interface Builder just saves you from writing certain code; everything you do in IB can be done in code.

Try this in the View Controller, usually in viewDidLoad:

self.webView.delegate = self;

(You don't HAVE to call 'self', I like to for reasons outside this thread)

Be sure that View Controller which owns the UIWebView implements UIWebViewDelegate in the header file.

UPDATE Also, this from the dev site:

"Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled."

Have you done this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜