Monday, June 3, 2013

UIWebView UIWebViewNavigationTypeOther example in Objective C (iOS).


UIWebView UIWebViewNavigationTypeOther

UIWebViewNavigationType
Constant indicating the user’s action.

enum {
UIWebViewNavigationTypeLinkClicked,
UIWebViewNavigationTypeFormSubmitted,
UIWebViewNavigationTypeBackForward,
UIWebViewNavigationTypeReload,
UIWebViewNavigationTypeFormResubmitted,
UIWebViewNavigationTypeOther
};
typedef NSUInteger UIWebViewNavigationType;

Constants
UIWebViewNavigationTypeLinkClicked
User tapped a link.
UIWebViewNavigationTypeFormSubmitted
User submitted a form.
UIWebViewNavigationTypeBackForward
User tapped the back or forward button.
UIWebViewNavigationTypeReload
User tapped the reload button.
UIWebViewNavigationTypeFormResubmitted
User resubmitted a form.
UIWebViewNavigationTypeOther
Some other action occurred.

UIWebView UIWebViewNavigationTypeOther example.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
DrillDownWebExampleAppDelegate *appDelegate =
(DrillDownWebExampleAppDelegate *)[[UIApplication sharedApplication] delegate];

if(navigationType == UIWebViewNavigationTypeOther)
{
    NSURL *url2 = [request URL];
    NSString *URLStr = [url2 absoluteString];

    RootViewController* viewController = [[RootViewController alloc] init];
    NSString *holder = [self getQueryStringInner:URLStr];
    [self getQueryString:URLStr];
    if([holder length] != 0 )
    {
        appDelegate.title =@"Title";
        appDelegate.query = queryString;
        [self.navigationController pushViewController:viewController animated:YES];
        [viewController release];
        return NO;
    }


}
return YES;
}

Example of [UIWebView UIWebViewNavigationTypeOther].
- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
  if (navigationType != UIWebViewNavigationTypeOther) {
    self.outStandingLoads = 0;
  }
  return YES;
}

End of UIWebView UIWebViewNavigationTypeOther example article.