0

Currently i am working in iPhone application, Using UIWebview to load address like "America", then run the application, the map not shown on the screen. I want to shown the location from User enter search bar field, How to fix this iuissue? please help me

Thanks in Advance

I tried this:

    webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 40, 320,376)];
    webView.delegate=self;
    webView.scalesPageToFit=YES;
    NSString *mapurl = @"http://maps.google.com/maps?q=";
    NSString *urlString1 = [mapurl stringByAppendingFormat:@"America"];    
    NSString *OmitSpace = [urlString1 stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

    NSURL *url=[NSURL URLWithString:OmitSpace];
    NSURLRequest *requestObj=[NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];

Screen shot: enter image description here

SampathKumar
  • 2,525
  • 8
  • 47
  • 82

1 Answers1

0
NSString *OmitSpace = [urlString1 stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

This will omit the whitespace only. It will not convert other escape characters. So replace above line with this.

NSString *OmitSpace = [urlString1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
Ramaraj T
  • 5,184
  • 4
  • 35
  • 68