[iPhone開発]アプリからSafari起動し指定したURLを開く

忘れちまわないようにメモ

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.co.jp/"]];

でアプリ上から、指定したURLをSafariで開くことが出来るみたい。

ちなみにWebViewを使用する場合は下記。

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString: @"http://www.google.co.jp/"]];
// ブラウザを開く
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.size.height -= 40.0;
webView = [[[UIWebView alloc] initWithFrame:webFrame] autorelease];
webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
webView.scalesPageToFit = YES;
 
[self.view addSubview:webView]; 
[self.webView loadRequest:request];

投稿者:

kishir

趣味: sk8, ピスト、ターンテーブル、レコード 仕事: Python, Objective-C, PHP, JavaScript

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です