trying to get a link to open in the appstore not inside a locked webview, I have this so far in my viewcontroller.m file but have been unsucessful
Code:
@implementation WebViewController
-(id) init {
self = [super init];
if (self != nil){
webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
webView.scalesPageToFit = NO;
[self.view addSubview:webView];
NSURL *url = [NSURL fileURLWithPath:[ [ NSBundle mainBundle ] pathForResource: @"index" ofType:@"html" ]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}
return self;
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
NSURL *url = [request URL];
if (![[url scheme] hasPrefix:@"file"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
}
return YES;
}
also tried this to no avail.
Code:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
if ([[[request URL] host] isEqualToString:@"phobos.apple.com"])
{
NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:[request URL]] delegate:self startImmediately:YES];
[conn release];
return NO;
}
return YES;
}
what am I doing wrong?