Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-21-2010, 06:23 PM   #1 (permalink)
breathing
 
Join Date: Aug 2010
Posts: 48
sl4ter is on a distinguished road
Default webview app, opening appstore link in appstore app

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?
sl4ter is offline   Reply With Quote
Old 09-21-2010, 10:58 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 139
dudeofswim is on a distinguished road
Default

Quote:
Originally Posted by sl4ter View Post
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?
You dont need that much code. Just a button that opens safari with your desired link
dudeofswim is offline   Reply With Quote
Old 09-22-2010, 02:55 AM   #3 (permalink)
breathing
 
Join Date: Aug 2010
Posts: 48
sl4ter is on a distinguished road
Default

its not much code, the app loads up static files and im trying to get it to open an external link instead of internally in the webview, any idea?
sl4ter is offline   Reply With Quote
Old 09-22-2010, 03:25 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 11
geniusprograms is on a distinguished road
Default

Quote:
Originally Posted by sl4ter View Post
its not much code, the app loads up static files and im trying to get it to open an external link instead of internally in the webview, any idea?
If you're trying to open Safari with your page, then use something like this:
Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.website.com"]];
__________________

Coding is the easy bit. The hard bit is figuring out what code to write

My app (Documentation): Here
geniusprograms is offline   Reply With Quote
Reply

Bookmarks

Tags
appstore, iphone, itunes, webview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 346
13 members and 333 guests
2ndSegment, cgokey, djohnson, Domele, Hamad, linkmx, markuschow, mistergreen2011, Objective Zero, pungs, revg, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0