开发者

UIWebView loaded from another class, where to put delegate methods?

I'm loading in a UIWebView from another class, and that works great.

But now I need to know how I can implement these delegate methods:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
// AND:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

I have tried to do it in the other class, but that did not work. I also tried it in the class that fills/loads data into the UIWebView, but that didn't work either. I have set the UIWebView-referance in the 开发者_运维知识库.h-files, and everything should work, but it doesen't.

Any help will be appreciated. Thanks ! :)


After you create the UIWebView in your "other class" (aka UIViewController) you need to set the delegate of the UIWebView to the object that implements the delegate protocol methods. This is typically the controller that created the webView.

Take a look at the UICatalog sample project files WebViewController.h|m for hints as to how this should be done.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜