Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect UIWebView form submission in XCode

I've read the posts here, but cannot quite adapt them to my needs. I have:

-(IBAction) abouthtml
{
NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
CGRect webViewRect = frameWebSpace;
UIWebView *myWebPage=[[UIWebView alloc] initWithFrame:webViewRect];
[myWebPage loadRequest:requestObj];
[self.view addSubview:myWebPage];
}

This displays fine, but my "Return to Program" submit button in about.html is not working.

I've tried, as suggested in posts here:

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request 
navigationType:(UIWebViewNavigationType)navigationType 
{
if (navigationType == UIWebViewNavigationTypeFormSubmitted) 
{
     ....

But obviously, nothing links myWebPage to webView. Can someone suggest what I'm missing? Do I need to make webView a delegate of myWebPage? Confused, but hopeful...

like image 228
Bill Spivey Avatar asked Aug 01 '26 17:08

Bill Spivey


1 Answers

you have to set the delegate of UIWebView to be the object that implements shouldStartLoadWithRequest, [myWebPage setDelegate:self], assuming that class that adds the subview is the one you want to receive the shouldStartLoadWithRequest message

like image 93
Daniel Avatar answered Aug 04 '26 05:08

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!