views:

23

answers:

0

Hi,

I am trying to launch an external safari when I click on a hyperlink in UIWebView but in my case nothing happens. If I try to include target as blank and skip the UIWebView delegate method it launches the safari within the same view..please guide me friends how to open an external browser when tapped on a link in UIWebView..here is my code..I am creating UIWebView programmatically

CGRect webFrame = CGRectMake(10,78,300,50);  
         contactUsView.delegate = self;
         contactUsView = [[UIWebView alloc] initWithFrame:webFrame];  
         [contactUsView setOpaque:NO];
         contactUsView.backgroundColor = [UIColor clearColor];  
        NSString *html = @"<html><head></head><body>Copyright \u00A9 2010 <a href='http://www.example.com'&gt;Hello&lt;/a&gt;&lt;br/&gt;Hi  <a href='http://example1.com&gt;Click here</a></body></html>";  
         [contactUsView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://www.solstice-consulting.com"]]; 



- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request  
 navigationType:(UIWebViewNavigationType)navigationType; {  

    NSURL *requestURL = [ [ request URL ] retain ];  
    NSLog(@"expected:%d, got:%d", UIWebViewNavigationTypeLinkClicked, navigationType);

    if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ]  
          || [ [ requestURL scheme ] isEqualToString: @"https" ] )  
        && (navigationType == UIWebViewNavigationTypeLinkClicked ) ) {  
        return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];  
    }  

    [ requestURL release ];  

    return YES;  
}  

The log outputs expected as 0 and got as 5..I don't understand what to do..