0

I have a button in my view. On clicking it leads to a webview in which I want to show the maps. The code I am using is:

- (void)viewWillAppear:(BOOL)animated{
    NSString *url =  [@"http://maps.apple.com/?q=" stringByAppendingString:self.address];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    NSURLRequest *metricsRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
    _webViewForLocation.delegate = self;
    [_webViewForLocation loadRequest:metricsRequest];
    NSLog(@"Maps String: %@", url);
}

But the webview is blank. HOw do I show maps in it?

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
Vamshi Krishna
  • 979
  • 9
  • 19

1 Answers1

0

try

- (void)viewDidLoad
{
[super viewDidLoad];

[_webViewForLocation loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/?q=bangalore"]]]];  // here pass your string


- (void)webViewDidStartLoad:(UIWebView *)webView
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{

 }



- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

the output is

enter image description here

refers this document,

Community
  • 1
  • 1
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143