22 Oct 2010, 15:20
Current_pragsmall

Matthew Gallagher (3 posts)

I must have hit my head, because I cannot for the life of me get the detailsURL to open in a UIWebView rather than mobile Safari.

I have added a webview.h/m to the project and tried to incorporate that into the flow so that the detailsURL opens within the app rather than spawning Mobile Safari.


#import <UIKit/UIKit.h>
@interface webview : UIViewController <UIWebViewDelegate> {
    IBOutlet UIWebView *webview;
}
@property (nonatomic, retain) IBOutlet UIWebView *webview;
@end

webview.m where I synthesize and release the UIWebView.

I have imported the webview and added varying test snippets of code to the MapQuakesViewController.m file in hopes of getting the detail screen to open within the app.


- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
    EarthquakeAnnotation *eqAnn = (EarthquakeAnnotation *)[view annotation];

    /*UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)];  
    webView.delegate = self;
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString: eqAnn.earthquake.detailsURL]];  
    //[self.webView loadRequest:request]; 
    [webView loadRequest:request];*/

    /*UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)];  
    webView.delegate = self;
    NSURL *url = [NSURL URLWithString:eqAnn.earthquake.detailsURL];
    NSURLRequest *request = [NSURLRequest requestWithURL: url];
    [webView loadRequest:request];*/

    UIWebView *webview = [[UIWebView alloc] initWithNibName:@"webview" bundle:nil];
    NSURL *url = [NSURL URLWithString:eqAnn.earthquake.detailsURL];
    NSURLRequest *request = [NSURLRequest requestWithURL: url];
    [webview loadRequest:[[request copy] autorelease]];
    [webview release];

    /*
    UIViewController *webview = [[UIViewController alloc] init];
    [self.navigationController pushViewController:webview animated:YES];
    NSURL *url = [NSURL URLWithString:eqAnn.earthquake.detailsURL];
    NSURLRequest *request = [NSURLRequest requestWithURL: url];
    [webview loadRequest:request];    
    [webview release];*/
}

No matter what I try, I cannot get this little bugger to work for me. I am sure it is something simple I am overlooking but I could sure use a little guidance to solve this problem.

tia

  You must be logged in to comment