TableViewには「方向」ボタンがあり、クリックすると対応するURLでGoogleマップが開きます。WebViewにGoogleMapsをロードする必要がありますが、WebViewをロードできませんでした。
ViewController.h:
@property(nonatomic,retain)BusinessNearbyLocationsMapView *businessNearbyLocationMapView;
In ViewController.m:
@synthesize businessNearbyLocationMapView;
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *image = [UIImage imageNamed: @"ic_launcher.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
imageView.frame =CGRectMake(0,0,120,50);
[self.navigationBar setFrame:CGRectMake(0,0,320,70)];
self.navigationBar.tintColor=[UIColor whiteColor];
[self.navigationBar addSubview:imageView];
[imageView release];
}
-(IBAction)showDirections:(id)sender
{
selectedRow=[sender tag];
NSMutableDictionary * location = [[[places objectAtIndex:selectedRow]objectForKey:@"geometry"]objectForKey:@"location"];
NSString * lat = [location objectForKey:@"lat"];
NSString * lng = [location objectForKey:@"lng"];
AppAppDelegate *appDelegate=(AppAppDelegate *)[[UIApplication sharedApplication]delegate];
businessNearbyLocationMapView.url =@"http://maps.google.com/maps?saddr=%f,%f&daddr=%@,%@",appDelegate.userlatitude,appDelegate.userlongitude,lat,lng;
[self.navigationController pushViewController:self.businessNearbyLocationMapView animated:YES];
}
BusinessNearbyLocationsMapView.m:
- (void)viewWillAppear:(BOOL)animated {
NSString *fullUrl = [[NSString alloc] initWithFormat:@"http://%@", self.url];
NSURL *aboutURL = [[NSURL alloc] initWithString:fullUrl];
[fullUrl release];
[viewWebView loadRequest:[NSURLRequest requestWithURL:aboutURL]];
[super viewWillAppear:animated];
}
しかし、対応するURLがロードされたWebビューを見ることができませんでしたか?どこが間違っているのですか?